Commit 592897b0 authored by Ken Martin's avatar Ken Martin
Browse files

Added some methods and fixed some minor errors

parent 53406cf8
......@@ -45,6 +45,8 @@ class vlTransform : public vlObject
// the stack is the current transformation matrix.
vlMatrix4x4 ** StackBottom;
// The bottom of the stack.
float Vector[4];
// a temp vector used in operations
public:
vlTransform ();
// Constructs a transform. Sets the following defaults:
......@@ -130,6 +132,13 @@ class vlTransform : public vlObject
// Multiplies two 4 x 4 matrices and produces a
// 4 x 4 matrix. The output matrix can be the
// same as either of the two input matrices.
void VectorMultiply (float in[4],float out[4])
{this->Stack[0]->VectorMultiply(in,out);};
// Multiplies two 4 x 4 matrices and produces a
// 4 x 4 matrix. The output matrix can be the
// same as either of the two input matrices.
vlSetVector4Macro(Vector,float);
float *GetVector();
};
#endif
......@@ -191,9 +191,6 @@ void vlTransform::RotateWXYZ ( float angle, float x, float y, float z)
vlMatrix4x4 ctm;
float radians;
float w;
float x;
float y;
float z;
float sum;
float quat[4];
float sin_angle;
......@@ -214,17 +211,21 @@ void vlTransform::RotateWXYZ ( float angle, float x, float y, float z)
sin_angle = sin (radians);
// normalize x, y, z
if (sum = quat[1] * quat[1] + quat[2] * quat[2] + quat[3] * quat[3]) {
if (sum = quat[1] * quat[1] + quat[2] * quat[2] + quat[3] * quat[3])
{
quat[1] *= sin_angle / sqrt(sum);
quat[2] *= sin_angle / sqrt(sum);
quat[3] *= sin_angle / sqrt(sum);
}
else {
}
else
{
return;
}
}
w = cos_angle;
x = quat[1];
y = quat[2];
z = quat[3];
ctm = 0.0;
......@@ -538,3 +539,8 @@ void vlTransform::PrintSelf (ostream& os, vlIndent indent)
}
}
float *vlTransform::GetVector()
{
this->Stack[0]->VectorMultiply(this->Vector,this->Vector);
return this->Vector;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment