#include <stdio.h>
// Define a structure to hold 3D points
typedef struct {
float x;
float y;
float z;
} Point3D;
// Function to reflect a point in the XY plane (flip z-axis)
Point3D reflectXY(Point3D p) {
p.z = -p.z;
return p;
}
// Function to reflect a point in the YZ plane (flip x-axis)
Point3D reflectYZ(Point3D p) {
p.x = -p.x;
return p;
}
// Function to reflect a point in the ZX plane (flip y-axis)
Point3D reflectZX(Point3D p) {
p.y = -p.y;
return p;
}
int main() {
// Define a 3D point
Point3D point = {3.0f, 4.0f, 5.0f};
// Print the original point
printf("Original point: (%.2f, %.2f, %.2f)\n", point.
x, point.
y, point.
z);
// Reflect the point in the XY plane
Point3D reflectedXY = reflectXY(point);
printf("Reflection in XY plane: (%.2f, %.2f, %.2f)\n", reflectedXY.
x, reflectedXY.
y, reflectedXY.
z);
// Reflect the point in the YZ plane
Point3D reflectedYZ = reflectYZ(point);
printf("Reflection in YZ plane: (%.2f, %.2f, %.2f)\n", reflectedYZ.
x, reflectedYZ.
y, reflectedYZ.
z);
// Reflect the point in the ZX plane
Point3D reflectedZX = reflectZX(point);
printf("Reflection in ZX plane: (%.2f, %.2f, %.2f)\n", reflectedZX.
x, reflectedZX.
y, reflectedZX.
z);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBEZWZpbmUgYSBzdHJ1Y3R1cmUgdG8gaG9sZCAzRCBwb2ludHMKdHlwZWRlZiBzdHJ1Y3QgewogICAgZmxvYXQgeDsKICAgIGZsb2F0IHk7CiAgICBmbG9hdCB6Owp9IFBvaW50M0Q7CgovLyBGdW5jdGlvbiB0byByZWZsZWN0IGEgcG9pbnQgaW4gdGhlIFhZIHBsYW5lIChmbGlwIHotYXhpcykKUG9pbnQzRCByZWZsZWN0WFkoUG9pbnQzRCBwKSB7CiAgICBwLnogPSAtcC56OwogICAgcmV0dXJuIHA7Cn0KCi8vIEZ1bmN0aW9uIHRvIHJlZmxlY3QgYSBwb2ludCBpbiB0aGUgWVogcGxhbmUgKGZsaXAgeC1heGlzK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0gcmVmbGVjdFpYKHBvaW50KTsKICAgIHByaW50ZigiUmVmbGVjdGlvbiBpbiBaWCBwbGFuZTogKCUuMmYsICUuMmYsICUuMmYpXG4iLCByZWZsZWN0ZWRaWC54LCByZWZsZWN0ZWRaWC55LCByZWZsZWN0ZWRaWC56KTsKCiAgICByZXR1cm4gMDsKfQo=
Original point: (3.00, 4.00, 5.00)
Reflection in XY plane: (3.00, 4.00, -5.00)
Reflection in YZ plane: (-3.00, 4.00, 5.00)
Reflection in ZX plane: (3.00, -4.00, 5.00)