198#define Point2fT Tuple2fT
200#define Quat4fT Tuple4fT
202#define Vector2fT Tuple2fT
203#define Vector3fT Tuple3fT
206#define FuncSqrt sqrtf
210# define Epsilon 1.0e-5
226 assert(NewObj && v1 && v2);
231 Result.s.X = (v1->s.Y * v2->s.Z) - (v1->s.Z * v2->s.Y);
232 Result.s.Y = (v1->s.Z * v2->s.X) - (v1->s.X * v2->s.Z);
233 Result.s.Z = (v1->s.X * v2->s.Y) - (v1->s.Y * v2->s.X);
246 assert(NewObj && v1);
248 return (NewObj->s.X * v1->s.X) +
249 (NewObj->s.Y * v1->s.Y) + (NewObj->s.Z * v1->s.Z);
257static float Vector3fLengthSquared(
const Vector3fT * NewObj)
261 return (NewObj->s.X * NewObj->s.X) +
262 (NewObj->s.Y * NewObj->s.Y) + (NewObj->s.Z * NewObj->s.Z);
270static float Vector3fLength(
const Vector3fT * NewObj)
274 return FuncSqrt(Vector3fLengthSquared(NewObj));
284static void Matrix3fSetRotationFromQuat4f(
Matrix3fT * NewObj,
293 assert(NewObj && q1);
295 n = (q1->s.X * q1->s.X) + (q1->s.Y * q1->s.Y) + (q1->s.Z * q1->s.Z) +
297 s = (n > 0.0f) ? (2.0f / n) : 0.0f;
312 NewObj->
s.
XX = 1.0f - (yy + zz);
313 NewObj->
s.
YX = xy - wz;
314 NewObj->
s.
ZX = xz + wy;
315 NewObj->
s.
XY = xy + wz;
316 NewObj->
s.
YY = 1.0f - (xx + zz);
317 NewObj->
s.
ZY = yz - wx;
318 NewObj->
s.
XZ = xz - wy;
319 NewObj->
s.
YZ = yz + wx;
320 NewObj->
s.
ZZ = 1.0f - (xx + yy);
333 assert(NewObj && m1);
371static void Matrix4fSetRotationScaleFromMatrix4f(
Matrix4fT * NewObj,
374 assert(NewObj && m1);
407 (NewObj->
s.
XY * NewObj->
s.
XY) +
408 (NewObj->
s.
XZ * NewObj->
s.
XZ) +
409 (NewObj->
s.
YX * NewObj->
s.
YX) +
410 (NewObj->
s.
YY * NewObj->
s.
YY) +
411 (NewObj->
s.
YZ * NewObj->
s.
YZ) +
412 (NewObj->
s.
ZX * NewObj->
s.
ZX) +
413 (NewObj->
s.
ZY * NewObj->
s.
ZY) +
414 (NewObj->
s.
ZZ * NewObj->
s.
ZZ)) / 3.0f);
418 rot3->
s.
XX = NewObj->
s.
XX;
419 rot3->
s.
XY = NewObj->
s.
XY;
420 rot3->
s.
XZ = NewObj->
s.
XZ;
421 rot3->
s.
YX = NewObj->
s.
YX;
422 rot3->
s.
YY = NewObj->
s.
YY;
423 rot3->
s.
YZ = NewObj->
s.
YZ;
424 rot3->
s.
ZX = NewObj->
s.
ZX;
425 rot3->
s.
ZY = NewObj->
s.
ZY;
426 rot3->
s.
ZZ = NewObj->
s.
ZZ;
431 (NewObj->
s.
XY * NewObj->
s.
XY) +
432 (NewObj->
s.
XZ * NewObj->
s.
XZ));
438 (NewObj->
s.
YY * NewObj->
s.
YY) +
439 (NewObj->
s.
YZ * NewObj->
s.
YZ));
445 (NewObj->
s.
ZY * NewObj->
s.
ZY) +
446 (NewObj->
s.
ZZ * NewObj->
s.
ZZ));
454 if (rot4 != NewObj) {
455 Matrix4fSetRotationScaleFromMatrix4f(rot4, NewObj);
460 (NewObj->
s.
XY * NewObj->
s.
XY) +
461 (NewObj->
s.
XZ * NewObj->
s.
XZ));
467 (NewObj->
s.
YY * NewObj->
s.
YY) +
468 (NewObj->
s.
YZ * NewObj->
s.
YZ));
474 (NewObj->
s.
ZY * NewObj->
s.
ZY) +
475 (NewObj->
s.
ZZ * NewObj->
s.
ZZ));
485static void Matrix4fSetRotationScaleFromMatrix3f(
Matrix4fT * NewObj,
488 assert(NewObj && m1);
502static void Matrix4fMulRotationScale(
Matrix4fT * NewObj,
float scale)
528static void Matrix4fSetRotationFromMatrix3f(
Matrix4fT * NewObj,
533 assert(NewObj && m1);
537 Matrix4fSetRotationScaleFromMatrix3f(NewObj, m1);
538 Matrix4fMulRotationScale(NewObj,
scale);
void init_arcBall(ArcBall_t *a, float NewWidth, float NewHeight)
#define X(prefix, name, str, type, subtype,...)
static pointf scale(double c, pointf p)