Loading [MathJax]/extensions/tex2jax.js
ProtoTracer  1.0
Real-time 3D rendering and animation engine
All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
ObjectAlign.cpp
Go to the documentation of this file.
1#include "ObjectAlign.h"
2
4 Object3D** objs = new Object3D*[1];
5 objs[0] = obj;
6
7 Vector3D output = GetCentroid(objs, 1);
8
9 delete[] objs;
10
11 return output;
12}
13
14Vector3D ObjectAlign::GetCentroid(Object3D** objs, uint8_t numObjects) {
15 Vector3D centroid;
16 uint16_t vertexCount = 0;
17
18 for (uint8_t i = 0; i < numObjects; i++) {
19 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
20 vertexCount++;
21 centroid = centroid + objs[i]->GetTriangleGroup()->GetVertices()[j];
22 }
23 }
24
25 centroid = centroid / float(vertexCount);
26
27 return centroid;
28}
29
31 Object3D** objs = new Object3D*[1];
32 objs[0] = obj;
33
34 Vector3D output = GetObjectCenter(objs, 1);
35
36 delete[] objs;
37
38 return output;
39}
40
41Vector3D ObjectAlign::GetObjectCenter(Object3D** objs, uint8_t numObjects) {
42 Vector3D min = Vector3D(100000.0f, 100000.0f, 100000.0f), max = Vector3D(-100000.0f, -100000.0f, -100000.0f);
43
44 for (uint8_t i = 0; i < numObjects; i++) {
45 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
46 Vector3D vertex = objs[i]->GetTriangleGroup()->GetVertices()[j];
47
48 min = Vector3D::Min(min, vertex);
49 max = Vector3D::Max(max, vertex);
50 }
51 }
52
53 return (max + min) / 2.0f;
54}
55
57 Object3D** objs = new Object3D*[1];
58 objs[0] = obj;
59
60 Vector3D output = GetObjectSize(objs, 1);
61
62 delete[] objs;
63
64 return output;
65}
66
67Vector3D ObjectAlign::GetObjectSize(Object3D** objs, uint8_t numObjects) {
68 Vector3D min = Vector3D(100000.0f, 100000.0f, 100000.0f), max = Vector3D(-100000.0f, -100000.0f, -100000.0f);
69
70 for (uint8_t i = 0; i < numObjects; i++) {
71 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
72 Vector3D modifiedVector = objs[i]->GetTriangleGroup()->GetVertices()[j];
73
74 min = Vector3D::Min(min, modifiedVector);
75 max = Vector3D::Max(max, modifiedVector);
76
77 objs[i]->GetTriangleGroup()->GetVertices()[j] = modifiedVector;
78 }
79 }
80
81 return max - min;
82}
83
84void ObjectAlign::NormalizeObjectPlane(Object3D** objs, uint8_t numObjects, Vector3D center, Quaternion planeOrientation) {
85 for (uint8_t i = 0; i < numObjects; i++) {
86 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
87 Vector3D modifiedVector = objs[i]->GetTriangleGroup()->GetVertices()[j];
88
89 modifiedVector = modifiedVector - center;
90 modifiedVector = planeOrientation.UnrotateVector(modifiedVector);
91
92 objs[i]->GetTriangleGroup()->GetVertices()[j] = modifiedVector;
93 }
94 }
95}
96
97void ObjectAlign::NormalizeObjectCenter(Object3D** objs, uint8_t numObjects, Vector3D center) {
98 for (uint8_t i = 0; i < numObjects; i++) {
99 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
100 Vector3D modifiedVector = objs[i]->GetTriangleGroup()->GetVertices()[j];
101
102 modifiedVector = modifiedVector - center;
103
104 objs[i]->GetTriangleGroup()->GetVertices()[j] = modifiedVector;
105 }
106 }
107}
108
110 Object3D** objs = new Object3D*[1];
111 objs[0] = obj;
112
113 float planarity = GetObjectPlanarityRatio(objs, 1);
114
115 delete[] objs;
116
117 return planarity;
118}
119
120// Main function to check planarity of objects
121float ObjectAlign::GetObjectPlanarityRatio(Object3D** objs, uint8_t numObjects) {
122 // Calculate centroid and plane orientation
123 Vector3D centroid = GetCentroid(objs, numObjects);
124 Quaternion planeOrientation = GetPlaneOrientation(objs, numObjects, centroid);
125
126 uint16_t totalVertices = 0;
127 Vector3D diffSum = Vector3D();
128
129 for (uint8_t i = 0; i < numObjects; i++) {
130 totalVertices += objs[i]->GetTriangleGroup()->GetVertexCount();// Determine total number of vertices
131
132 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
133 Vector3D vertex = objs[i]->GetTriangleGroup()->GetVertices()[j];
134 Vector3D diff = vertex - centroid;
135 Vector3D diffRot = planeOrientation.RotateVector(diff);
136
137 diffSum = diffSum + diffRot.Absolute();
138 }
139 }
140
141 diffSum = diffSum / totalVertices;
142
143 // Inverse of difference in scale of object in reference to best fit plane orientation. 0.0f for a sphere -> 1.0f for a plane
144 return 1.0f - 1.0f / (diffSum / Mathematics::Min(diffSum.X, diffSum.Y, diffSum.Z)).AverageHighestTwoComponents();
145}
146
148 Object3D** objs = new Object3D*[1];
149 objs[0] = obj;
150
151 Quaternion output = GetPlaneNormal(objs, 1);
152
153 delete[] objs;
154
155 return output;
156}
157
159 Vector3D normal;
160 uint16_t count = 0;
161
162 for (uint8_t i = 0; i < numObjects; i++) {
163 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetTriangleCount(); j++) {
164 normal = normal + *(objs[i]->GetTriangleGroup()->GetTriangles()[j].Normal());
165
166 count++;
167 }
168 }
169
170 normal = normal / count;
171 normal = normal.UnitSphere().Absolute();
172
173 Quaternion rotation = Rotation(Vector3D(0.0f, 0.0f, 1.0f), normal).GetQuaternion();
174
176
177 return rotation;
178}
179
181 Object3D** objs = new Object3D*[1];
182 objs[0] = obj;
183
184 Quaternion output = GetPlaneOrientation(objs, 1, centroid);
185
186 delete[] objs;
187
188 return output;
189}
190
191Quaternion ObjectAlign::GetPlaneOrientation(Object3D** objs, uint8_t numObjects, Vector3D centroid) {
192 float xx = 0.0f, xy = 0.0f, xz = 0.0f, yy = 0.0f, yz = 0.0f, zz = 0.0f;
193 uint16_t count = 0;
194
195 for (uint8_t i = 0; i < numObjects; i++) {
196 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
197 Vector3D off = objs[i]->GetTriangleGroup()->GetVertices()[j] - centroid;
198
199 xx += off.X * off.X;
200 xy += off.X * off.Y;
201 xz += off.X * off.Z;
202 yy += off.Y * off.Y;
203 yz += off.Y * off.Z;
204 zz += off.Z * off.Z;
205
206 count++;
207 }
208 }
209
210 float xD = yy * zz - yz * yz;
211 float yD = xx * zz - xz * xz;
212 float zD = xx * yy - xy * xy;
213
214 float maxDeterm = Mathematics::Max(xD, yD, zD);
215
216 if (maxDeterm <= 0.0f) return Quaternion();
217
218 Vector3D dir;
219
220 if (Mathematics::IsClose(maxDeterm, xD, 0.001f)) {
221 dir.X = xD;
222 dir.Y = xz * yz - xy * zz;
223 dir.Z = xy * yz - xz * yy;
224 } else if (Mathematics::IsClose(maxDeterm, yD, 0.001f)) {
225 dir.X = xz * yz - xy * zz;
226 dir.Y = yD;
227 dir.Z = xy * xz - yz * xx;
228 } else {
229 dir.X = xy * yz - xz * yy;
230 dir.Y = xy * xz - yz * xx;
231 dir.Z = xD;
232 }
233
234 dir = dir.UnitSphere();
235
236 //Serial.print(dir.ToString()); Serial.print('\t');
237 //Serial.print(xD); Serial.print('\t');
238 //Serial.print(yD); Serial.print('\t');
239 //Serial.print(zD); Serial.print('\t');
240 //Serial.print(Rotation(Vector3D(0.0f, 0.0f, 1.0f), dir).GetEulerAngles(EulerConstants::EulerOrderXYZS).Angles.ToString()); Serial.print('\n'); Serial.print('\n');
241
243}
244
245ObjectAlign::ObjectAlign(Vector2D camMin, Vector2D camMax, Quaternion targetOrientation) {
246 this->camMin = camMin;
247 this->camMax = camMax;
248 this->cameraCenter = (camMin + camMax) / 2.0f;
249 this->targetOrientation = targetOrientation;
250}
251
252void ObjectAlign::SetPlaneOffsetAngle(float offsetPlaneAngle) {
253 this->offsetPlaneAngle = offsetPlaneAngle;
254}
255
256void ObjectAlign::SetEdgeMargin(float edgeMargin) {
257 this->edgeMargin = edgeMargin * 2.0f;
258}
259
261 this->forwardVector = forwardVector;
262}
263
265 this->camMin = camMin;
266 this->cameraCenter = (camMin + camMax) / 2.0f;
267}
268
270 this->camMax = camMax;
271 this->cameraCenter = (camMin + camMax) / 2.0f;
272}
273
274void ObjectAlign::SetMirrorX(bool mirrorX) {
275 this->mirrorX = mirrorX;
276}
277
278void ObjectAlign::SetMirrorY(bool mirrorY) {
279 this->mirrorY = mirrorY;
280}
281
283 this->jst = jst;
284}
285
286void ObjectAlign::SetScale(float scaleX, float scaleY) {
287 this->scaleX = scaleX;
288 this->scaleY = scaleY;
289}
290
291//Aligns object, does not move or scale object
293 Object3D** objs = new Object3D*[1];
294 objs[0] = obj;
295 Transform objectCenter = GetTransform(objs, 1);
296 delete[] objs;
297
298 return objectCenter;
299}
300
301Transform ObjectAlign::GetTransform(Object3D** objs, uint8_t numObjects){
302 Transform newTransform;
303 // calculate planes, assume flat object (largest axes are axis), best fit plane i.e. centroid + direction/normal
304 Vector3D centroid = GetCentroid(objs, numObjects);
305 Quaternion planeOrientation = GetPlaneOrientation(objs, numObjects, centroid);
306 Vector2D cameraSize = (camMax - camMin);
307 Vector3D objectCenter = GetObjectCenter(objs, numObjects); // Get cameraCenter of objects
308
309 // Get new size of objects after normalization
310 Vector3D objectSize = GetObjectSize(objs, numObjects);
311
312 float xRatio = (cameraSize.X - edgeMargin) / objectSize.X;
313 float yRatio = (cameraSize.Y - edgeMargin) / objectSize.Y;
314
315 if (jst != Stretch) {
316 // Uniform object scaling with modifier
317 xRatio = Mathematics::Min(xRatio, yRatio) * scaleX;
318 yRatio = Mathematics::Min(xRatio, yRatio) * scaleY;
319 }
320
321 float xOffset = ((cameraSize.X - edgeMargin) - (xRatio * objectSize.X)) / 2.0f; // get left over space between camera edge and object in X-axis view
322 float yOffset = ((cameraSize.Y - edgeMargin) - (yRatio * objectSize.Y)) / 2.0f; // get left over space between camera edge and object in Y-axis view
323
324 switch (jst) {
325 case UpperLeft:
326 // No Change
327 break;
328 case UpperMiddle:
329 xOffset = 0.0f;
330 break;
331 case UpperRight:
332 xOffset = -xOffset;
333 break;
334 case MiddleLeft:
335 yOffset = 0.0f;
336 break;
337 case MiddleRight:
338 xOffset = -xOffset;
339 yOffset = 0.0f;
340 break;
341 case LowerLeft:
342 yOffset = -yOffset;
343 break;
344 case LowerMiddle:
345 xOffset = 0.0f;
346 yOffset = -yOffset;
347 break;
348 case LowerRight:
349 xOffset = -xOffset;
350 yOffset = -yOffset;
351 break;
352 default: // Middle
353 xOffset = 0.0f;
354 yOffset = 0.0f;
355 break;
356 }
357
358 // calculate point 250mm in front of camera
360 Quaternion outputQuaternion = planeOrientation.Conjugate().Multiply(targetOrientation);
361
362 newTransform.SetPosition(Vector3D(xOffset, yOffset, 0.0f) + cameraTarget - objectCenter);
363 newTransform.SetRotation(outputQuaternion);
364 newTransform.SetRotationOffset(objectCenter);
365 newTransform.SetScale(Vector3D(xRatio, yRatio, 1.0f) * Vector3D(mirrorX ? -1.0f : 1.0f, mirrorY ? -1.0f : 1.0f, 1.0f));
366
367 return newTransform;
368}
369
371 Object3D** objs = new Object3D*[1];
372 objs[0] = obj;
373 AlignObjectsNoScale(objs, 1);
374 delete[] objs;
375}
376
377void ObjectAlign::AlignObjectsNoScale(Object3D** objs, uint8_t numObjects) {
378 Vector3D centroid = GetCentroid(objs, numObjects);
379 Quaternion planeOrientation = GetPlaneNormal(objs, numObjects);
380 Vector3D objectCenter = GetObjectCenter(objs, numObjects);
381 NormalizeObjectPlane(objs, numObjects, centroid, planeOrientation);
382 objectCenter = GetObjectCenter(objs, numObjects);
383 NormalizeObjectCenter(objs, numObjects, objectCenter);
385 for (uint8_t i = 0; i < numObjects; i++) {
386 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
387 Vector3D modifiedVector = objs[i]->GetTriangleGroup()->GetVertices()[j];
388 modifiedVector = modifiedVector * Vector3D(mirrorX ? -1.0f : 1.0f, mirrorY ? -1.0f : 1.0f, 1.0f);
389 modifiedVector = targetOrientation.RotateVector(modifiedVector);
390 modifiedVector = modifiedVector + cameraTarget;
391 objs[i]->GetTriangleGroup()->GetVertices()[j] = modifiedVector;
392 }
393 }
394}
395
397 Object3D** objs = new Object3D*[1];
398 objs[0] = obj;
399 AlignObjects(objs, 1);
400 delete[] objs;
401}
402
403void ObjectAlign::AlignObjects(Object3D** objs, uint8_t numObjects) {
404 // calculate planes, assume flat object (largest axes are axis), best fit plane i.e. centroid + direction/normal
405 Vector3D centroid = GetCentroid(objs, numObjects);
406 Quaternion planeOrientation = GetPlaneOrientation(objs, numObjects, centroid);
407 Vector2D cameraSize = (camMax - camMin);
408 Vector3D objectCenter = GetObjectCenter(objs, numObjects); // Get cameraCenter of objects
409
410 // Normalize objects to plane orientation and cameraCenter of object
411 NormalizeObjectPlane(objs, numObjects, centroid, planeOrientation);
412
413 objectCenter = GetObjectCenter(objs, numObjects); // Get cameraCenter of objects
414
415 NormalizeObjectCenter(objs, numObjects, objectCenter); // Shift object back to center of view
416
417 // Get new size of objects after normalization
418 Vector3D objectSize = GetObjectSize(objs, numObjects);
419
420 float xRatio = (cameraSize.X - edgeMargin) / objectSize.X;
421 float yRatio = (cameraSize.Y - edgeMargin) / objectSize.Y;
422
423 if (jst != Stretch) {
424 // Uniform object scaling with modifier
425 xRatio = Mathematics::Min(xRatio, yRatio) * scaleX;
426 yRatio = Mathematics::Min(xRatio, yRatio) * scaleY;
427 }
428
429 float xOffset = ((cameraSize.X - edgeMargin) - (xRatio * objectSize.X)) / 2.0f; // get left over space between camera edge and object in X-axis view
430 float yOffset = ((cameraSize.Y - edgeMargin) - (yRatio * objectSize.Y)) / 2.0f; // get left over space between camera edge and object in Y-axis view
431
432 switch (jst) {
433 case UpperLeft:
434 // No Change
435 break;
436 case UpperMiddle:
437 xOffset = 0.0f;
438 break;
439 case UpperRight:
440 xOffset = -xOffset;
441 break;
442 case MiddleLeft:
443 yOffset = 0.0f;
444 break;
445 case MiddleRight:
446 xOffset = -xOffset;
447 yOffset = 0.0f;
448 break;
449 case LowerLeft:
450 yOffset = -yOffset;
451 break;
452 case LowerMiddle:
453 xOffset = 0.0f;
454 yOffset = -yOffset;
455 break;
456 case LowerRight:
457 xOffset = -xOffset;
458 yOffset = -yOffset;
459 break;
460 default: // Middle
461 xOffset = 0.0f;
462 yOffset = 0.0f;
463 break;
464 }
465
466 // calculate point 250mm in front of camera
468
469 for (uint8_t i = 0; i < numObjects; i++) {
470 for (uint16_t j = 0; j < objs[i]->GetTriangleGroup()->GetVertexCount(); j++) {
471 Vector3D modifiedVector = objs[i]->GetTriangleGroup()->GetVertices()[j];
472
473 // scaled object normalized in default camera space
474 modifiedVector = modifiedVector * Vector3D(xRatio, yRatio, 1.0f) * Vector3D(mirrorX ? -1.0f : 1.0f, mirrorY ? -1.0f : 1.0f, 1.0f);
475
476 // move object in default camera space before rotation
477 modifiedVector = modifiedVector + Vector3D(xOffset, yOffset, 0.0f);
478
479 // align object plane to camera plane
480 modifiedVector = targetOrientation.RotateVector(modifiedVector);
481
482 // move object to 250mm point in front of camera
483 modifiedVector = modifiedVector + cameraTarget; // offset position
484
485 objs[i]->GetTriangleGroup()->GetVertices()[j] = modifiedVector;
486 }
487 }
488}
Provides the ObjectAlign class for aligning 3D objects within defined 2D camera bounds.
Encapsulates a 3D rotation using Euler angles and a specific order of application.
Definition EulerAngles.h:25
virtual Vector3D * GetVertices()=0
Retrieves the array of mutable vertices in the triangle group.
virtual int GetVertexCount()=0
Retrieves the total number of vertices in the group.
virtual Triangle3D * GetTriangles()=0
Retrieves the array of Triangle3D objects representing the triangles.
static T Min(T value1, T value2)
Returns the minimum of two values.
static bool IsClose(float v1, float v2, float epsilon)
Checks if two values are close within a specified epsilon.
static T Max(T value1, T value2)
Returns the maximum of two values.
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
ITriangleGroup * GetTriangleGroup()
Retrieves the modifiable geometry of the object.
Definition Object3D.cpp:72
void SetEdgeMargin(float edgeMargin)
Sets the margin to keep from the edges when aligning objects.
void AlignObjectNoScale(Object3D *obj)
Aligns a single Object3D within the camera bounds without applying the object's scaling factor.
void SetForwardVector(Vector3D forwardVector)
Sets the forward vector, i.e., which axis is considered "forward" for the alignment logic.
float scaleY
Scaling factor on the Y-axis.
Definition ObjectAlign.h:56
float GetObjectPlanarityRatio(Object3D *obj)
Computes how planar (flat) a single object is, typically as a ratio (0.0 = not planar,...
float offsetPlaneAngle
Additional rotation offset (plane offset angle in degrees or radians).
Definition ObjectAlign.h:53
Vector3D GetObjectSize(Object3D *obj)
Retrieves the bounding box size (width, height, depth) of a single object.
Quaternion GetPlaneNormal(Object3D *obj)
Determines the plane normal (as a Quaternion) of the object based on its geometry.
void NormalizeObjectCenter(Object3D **objs, uint8_t numObjects, Vector3D center)
Translates the center of multiple objects so that their average center matches the specified center.
Justification
Describes how the object(s) should be justified within the bounding box.
Definition ObjectAlign.h:33
@ MiddleLeft
Justify to the middle-left side of the bounding area.
Definition ObjectAlign.h:37
@ LowerMiddle
Align to the bottom center of the bounding area.
Definition ObjectAlign.h:41
@ MiddleRight
Align to the middle-right side of the bounding area.
Definition ObjectAlign.h:39
@ UpperLeft
Justify to the upper-left corner of the bounding area.
Definition ObjectAlign.h:34
@ Stretch
Attempt to scale the object(s) to fill the entire area.
Definition ObjectAlign.h:43
@ UpperRight
Justify to the upper-right corner of the bounding area.
Definition ObjectAlign.h:36
@ UpperMiddle
Justify to the top center of the bounding area.
Definition ObjectAlign.h:35
@ LowerRight
Justify to the lower-right corner of the bounding area.
Definition ObjectAlign.h:42
@ LowerLeft
Justify to the lower-left corner of the bounding area.
Definition ObjectAlign.h:40
Transform GetTransform(Object3D *obj)
Computes the final Transform for aligning a single Object3D within the camera bounds.
Quaternion targetOrientation
Target orientation for aligning the object(s).
Definition ObjectAlign.h:48
void SetJustification(Justification jst)
Sets the justification mode for alignment.
ObjectAlign(Vector2D camMin, Vector2D camMax, Quaternion targetOrientation=Quaternion())
Constructor for ObjectAlign, setting up the camera bounds and orientation.
void NormalizeObjectPlane(Object3D **objs, uint8_t numObjects, Vector3D center, Quaternion planeOrientation)
Normalizes the orientation of multiple objects onto a plane.
Vector2D camMin
Minimum 2D camera bounds (lower-left).
Definition ObjectAlign.h:51
Vector3D GetCentroid(Object3D *obj)
Computes the centroid of the given object's geometry.
bool mirrorX
Whether to mirror objects along the X-axis.
Definition ObjectAlign.h:57
Justification jst
Current justification mode.
Definition ObjectAlign.h:47
Vector2D cameraCenter
Computed center between camMin and camMax.
Definition ObjectAlign.h:50
float edgeMargin
Margin from the bounding edges, in screen-space units.
Definition ObjectAlign.h:54
void SetPlaneOffsetAngle(float offsetPlaneAngle)
Sets the additional rotation offset (plane offset angle), in degrees or radians, that will be applied...
Vector3D GetObjectCenter(Object3D *obj)
Computes the "center" of a single object. Generally the same as centroid, but could be defined differ...
void AlignObjectsNoScale(Object3D **objs, uint8_t numObjects)
Aligns multiple objects without applying the object's scaling factor.
void AlignObject(Object3D *obj)
Aligns a single Object3D within the camera bounds, including applying scale factors as necessary.
Quaternion GetPlaneOrientation(Object3D *obj, Vector3D centroid)
Calculates the orientation needed to make the object's plane face the camera or align with a given ce...
void SetCameraMax(Vector2D camMax)
Updates the maximum bounds for the 2D camera region.
void AlignObjects(Object3D **objs, uint8_t numObjects)
Aligns multiple objects within the camera bounds, including scale factors.
bool mirrorY
Whether to mirror objects along the Y-axis.
Definition ObjectAlign.h:58
void SetMirrorX(bool mirrorX)
Enables or disables mirroring along the X-axis for the aligned objects.
Vector3D forwardVector
Default "forward" axis.
Definition ObjectAlign.h:49
float scaleX
Scaling factor on the X-axis.
Definition ObjectAlign.h:55
void SetMirrorY(bool mirrorY)
Enables or disables mirroring along the Y-axis for the aligned objects.
Vector2D camMax
Maximum 2D camera bounds (upper-right).
Definition ObjectAlign.h:52
void SetCameraMin(Vector2D camMin)
Updates the minimum bounds for the 2D camera region.
void SetScale(float scaleX, float scaleY)
Sets the scaling factors that will be applied to objects during alignment.
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Quaternion Conjugate() const
Returns the conjugate of this quaternion (W stays the same, X/Y/Z get negated).
Vector2D RotateVector(const Vector2D &v) const
Rotates a 2D vector by this quaternion, projecting it in 2D.
Vector2D UnrotateVector(const Vector2D &coordinate) const
Applies the inverse of this quaternion's rotation to a 2D vector.
Quaternion Multiply(const Quaternion &quaternion) const
Multiplies (composes) this quaternion with another (order matters).
Handles 3D rotations and conversions between various rotation representations.
Definition Rotation.h:32
Quaternion GetQuaternion()
Gets the quaternion representation of the rotation.
Definition Rotation.cpp:234
Represents a 3D transformation including position, rotation, and scale.
Definition Transform.h:22
void SetScale(const Vector3D &scale)
Sets the scale of the object.
Definition Transform.cpp:73
void SetPosition(const Vector3D &position)
Sets the position of the object.
Definition Transform.cpp:65
void SetRotationOffset(const Vector3D &rotationOffset)
Sets the rotation offset of the object.
Definition Transform.cpp:89
void SetRotation(const Quaternion &rotation)
Sets the current rotation of the object.
Definition Transform.cpp:53
Vector3D * Normal()
Calculates and returns the normal of the triangle.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
float X
The X-component of the 2D vector.
Definition Vector2D.h:29
float Y
The Y-component of the 2D vector.
Definition Vector2D.h:30
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26
float Max() const
Returns the maximum component value among X, Y, Z.
Definition Vector3D.cpp:176
float Min() const
Returns the minimum component value among X, Y, Z.
Definition Vector3D.cpp:180
float Z
The Z-component of the 3D vector.
Definition Vector3D.h:30
Vector3D UnitSphere() const
Normalizes this vector such that its magnitude is 1 (if non-zero).
Definition Vector3D.cpp:106
float X
The X-component of the 3D vector.
Definition Vector3D.h:28
float Y
The Y-component of the 3D vector.
Definition Vector3D.h:29
Vector3D Absolute() const
Returns a vector with the absolute value of each component.
Definition Vector3D.cpp:12
const EulerOrder EulerOrderXYZS
Order: X → Y → Z, static frame.