The Computer Graphics Companion Online Edition

Damian Scattergood 1999-2001

Index
Home

Download HelpFile

3D MATRIX TRANSFORMATIONS

3D TRANSLATION

3D translation can be achieved by either Multiplying by the Matrix translation T or by direct addition of Offsets to original
point.

Translate a given 3D point (PointX, PointY, PointZ) to a new position by the 3D distance (Dx, Dy, Dz).

void Translate_3DPoint ( PointX, PointY, PointZ, Dx, Dy, Dz)
// Depending on your implementation of the function
// the variables used maybe Integers or Floating point
// numbers
{
PointXnew = PointX + Dx;
PointYnew = PointY + Dy;
PointZnew = PointZ + Dz;
}

3D SCALING

To scale a point (PointX, PointY, PointZ) about the origin by Scaling factors Sx, Sy, Sz.

Note: Scaling using this method always takes place about the origin at (0,0,0);

void Scale_3DPoint ( PointX, PointY, PointZ, Sx, Sy, Sz )
{
PointXnew = PointX * Sx;
PointYnew = PointY * Sy;
PointZnew = PointZ * Sz;
}

3D Rotation about the X Axis

Rotates a point (PointX, PointY, PointZ) about the X axis by an angle of A degrees.
Note: Rotation takes place about the origin at (0,0,0);

void Rotate_3DPoint_XAxis ( PointX, PointY, PointZ, Angle )
{
PointXnew = PointX;
PointYnew = PointY * Cos(Angle) + PointZ * Sin(Angle);
PointZnew = PointZ * Cos(Angle) - PointY * Sin(Angle);
}

3D Rotation about the Y Axis

Rotates a point (PointX, PointY, PointZ) about the Y axis by an angle of A degrees.
Note: Rotation takes place about the origin at (0,0,0);

void Rotate_3DPoint_YAxis ( PointX, PointY, PointZ, Angle )
{
PointXnew = PointX * Cos(Angle) - PointZ * Sin(Angle);
PointYnew = PointY;
PointZnew = PointX * Sin(Angle) + PointZ * Cos(Angle);
}

3D Rotation about the Z Axis

Rotates a point (PointX, PointY, PointZ) about the Z axis by an angle of A degrees.
Note: Rotation takes place about the origin at (0,0,0);

void Rotate_3DPoint_ZAxis ( PointX, PointY, PointZ, Angle )
{
PointXnew = PointX * Cos(Angle) - PointY * Sin(Angle);
PointYnew = PointX * Sin(Angle) + PointY * Cos(Angle);
PointZnew = PointZ;
}

3D Perspective

Projects a point (PointX, PointY, PointZ) in Real space to a perspective view.

 

Perspective translation of given point (X,Y,Z) to the viewing plane is given by.

1