Vector3 A 3-dimensional vector class, with components x, y and z, and vareous functions. Matrix3 A 3x3 matrix class, with components a, b, c, d, e, f, g, h, i and various functions. Camera A 3D camera class full of handy functions for 3D transformations.

### QuickCG Vector3 Class Functions and Members

 Function Information x, y, z double x, double y, double z The 3 elements of the 3D vector. The vector is of the form [ x ] [ y ] [ z ] Vector3(double x, double y, double z);Constructor, create vector with given x, y and z coordinate Vector3();Constructor, create vector with x, y and z set to 0 length double length();Returns the length of the vector normalize void normalize();Normalizes the vector distance double distance(const Vector3& v);Returns the distance between this vector and v dot double dot(const Vector3& v);Returns the dot product between this vector and v cross Vector3 cross(const Vector3& v);Returns the cross product between this vector and v

### QuickCG Matrix3 Class Functions and Members

 Function Information a to i double a, double b, double c, double d, double e, double f, double g, double h, double iThe 9 elements of the 3x3 matrix. The matrix is of the form [ a b c ] [ d e f ] [ g h i ] Matrix3(double a, double b, double c, double d, double e, double f, double g, double h, double i);Constructor, create vector with given values for the elements. Matrix3();Constructor, create vector with all elements set to 0 transpose void transpose();Transpose the matrix determinant double determinant();Returns the determinant of the matrix invert void invert();Invert the matrix

### QuickCG Camera Class Functions and Members

White rows are public, grey rows are private.

 Function Information nearClip double nearClipThe near clipping distance of the camera farClip farClipThe far clipping distance of the camera Camera(double posx, double posy, double posz, double ux, double uy, double uz, double vx, double vy, double vz, double dirx, double diry, double dirz, double nearClip, double farClip); Generate the camera with given values Camera(); Generate the camera with default values getU, getV, getDir, getPos Vector3 getU(); Vector3 getV(); Vector3 getDir(); Vector3 getPos(); Returns the horizontal, vertical, direction or position vector of the camera setU, setV, setDir, setPos void setU(); void setV(); void setDir(); void setPos(); Sets the horizontal, vertical, direction or position vector of the camera move void move(const Vector3& offset); Move with given offset rotate void rotate(const Vector3& axis, double angle); Rotate the camera around given axis with given angle setLookDir void setLookDir(const Vector3& newDir); Let the camera look in given direction lookAt void lookAt(const Vector3& lookAtMe); Look at given point getDist, setDist double getDist(const Vector3& point); void setDist(const Vector3& point, double dist); Get and set the distance of the camera to a certain point (translate without rotating it) getZoomU, getZoomV double getZoomU(); double getZoomV(); Get the zoom value of the camera in horizontal or vertical direction setZoomU, setZoomV void setZoomU(double a); void setZoomV(double a); Set the zoom of the camera in horizontal or vertical direction zoom, zoomU, zoomV void zoom(double a); void zoomU(double a); void zoomV(double a); Zoom both horizontally and vertically, only horizontally or only vertically, with a certain factor. getFOVU, getFOVV double getFOVU(); double getFOVV(); Returns the Field Of View in horizontal or vertical direction in radians. This is just another way of describing the zoom, with an angle instead of a factor. setFOVU, setFOVV void setFOVU(double angle); void setFOVV(double angle); Set the Field Of View in horizontal or vertical direction. getYaw, getPitch, getRoll double getYaw(); double getPitch(); double getRoll(); Get those 3 Euler Angles from the camera. These aren't native members of the camera but have to be calculated out of its vectors. setYaw, setPitch, setRoll void setYaw(double angle); void setPitch(double angle); void setRoll(double angle); Get those 3 Euler Angles from the camera. These aren't native members of the camera but have to be converted to its vectors. yawPlanet, yawSpace, pitch, roll void yawPlanet(double angle); void yawSpace(double angle); void pitch(double angle); void roll(double angle); yawPlanet rotates the camera around the world y axis with given angle yawSpace rotates the camera around the camera "up" axis with given angle pitch rotates the camera around the camera "right" axis with given angle roll rotates the camera around the camera "direction" axis with given angle resetSkewU, resetSkewV Vector3 resetSkewU(); Vector3 resetSkewV(); Make the camera orthogonal again if somehow it became skewed. resetSkewU maintains exact direction and roll if only v was skewed resetSkewV maintains exact direction and roll if only u was skewed getRatioUV, getRatioVU double getRatioUV(); double getRatioVU(); Returns length(u)/length(v) and length(v)/length(u) respectively. setRatioUV, setRatioVU void setRatioUV(double ratio); void setRatioVU(double ratio); Sets the ratio of the length of u and v, to have a good view on the computer screen, ratioUV should match the resolution ratio of the screen, e.g. if using resolution 1024 * 768, then ratioUV should be set to 1024 / 768 = 1.333333 getScale, setScale, scale double getScale(); void setScale(double dirLength); void scale(double factor); Scaling the camera changes the length of u, v and dir with the same ratio. This has no effect on what you see. getScale returns the length of the direction vector, and setScale scales the camera until the direction vector has given length. generateMatrix void generateMatrix(); Generates the internal variable camMatrix. This matrix is nothing else than the column vectors u, v and dir sticked together, and is used for the transformation calculations. Generatematrix has to be used everytime you change u, v or dir. For the functions given above that rotate, scale, etc... this is already done automaticly. getMatrix setMatrix, Matrix3 getMatrix(); void setMatrix(const Matrix3& matrix); Get or set camMatrix. Setting it automaticly updates u, v and dir as well. transform Vector3 transform(const Vector3& v); Multiply given vector v with the inverse of camMatrix projectOnScreen bool projectOnScreen(const Vector3& point, int & x, int & y, double & z); bool projectOnScreen(const Vector3& point, int & x, int & y); Return the coordinates a certain 3D point has on screen. You can choose wether or not you want it to return the distance of that point to the screen in camera space. pos Vector3 pos; The position of the camera in the world u Vector3 u; The "right" vector of the camera, parallel with the horizontal bottom of the computer screen, the unit vector of the X axis of the camera space v Vector3 v; The "up" vector of the camera, parallel with the vertical side of the computer screen, the unit vector of the Y axis of the camera space dir Vector3 dir; The direction of the camera, where you're looking at, points into the computer screen, the unit vector of the Z axis of the camera space camMatrix Matrix3 camMatrix; The camera matrix for transformations. Should always be updated together with the u, v and dir vectors. invCamMatrix Matrix3 invCamMatrix; The inverse camera matrix for transformations. Should always be updated together with the u, v and dir vectors.

### QuickCG 3D Functions

 Function Information length double length(const Vector3& v); Returns the length of vector v normalize Vector3 normalize(const Vector3& v); Returns a vector with length 1 and the same direction as v distance double distance(const Vector3& v, const Vector3& w); Returns the distance between v and w dot double dot(const Vector3& v, const Vector3& w); Returns the dot product of v and w cross Vector3 cross(const Vector3& v, const Vector3& w); Returns the corss product of v and w - Vector3 operator-(const Vector3& v, const Vector3& w); Returns v - w - Vector3 operator-(const Vector3& v); Returns -v + Vector3 operator+(const Vector3& v, const Vector3& w); Returns v + w * Vector3 operator*(const Vector3& v, double a); const Vector3& operator*(double a, const Vector3& v); Returns v multiplied with a / Vector3 operator/(const Vector3& v, double a); Return v divided through a vectorAngle double vectorAngle(const Vector3& v, const Vector3& w); Return angle between vectors v and w rotateAroundArbitrary Vector3 rotateAroundArbitrary(const Vector3& v, const Vector3& axis, double angle); Returns vector v rotated around axis through the origin over the given angle transpose Matrix3 transpose(const Matrix3& A); Returns the transpose of A determinant double determinant(const Matrix3& A); Returns the determinant of A inverse Matrix3 inverse(const Matrix3& A); Returns the inverse of A + Matrix3 operator+(const Matrix3& A, const Matrix3& B); Returns A + B - Matrix3 operator-(const Matrix3& A, const Matrix3& B); Returns A - B * Matrix3 operator*(const Matrix3& A, double a); Matrix3 operator*(double a, const Matrix3& A); Returns A multiplied with a / Matrix3 operator/(const Matrix3& A, double a); Returns A divided through a * Vector3 operator*(const Matrix3& A, const Vector3& v); Vector3 operator*(const Vector3& v, const Matrix3& A); Matrix3 operator*(const Matrix3& A, const Matrix3& B); Returns matrix multiplied with vector, vector multiplied with matrix, or matrix multiplied with matrix radToDeg, degToRad double radToDeg(double rad); double degToRad(double deg); Convert from radians to degrees or from degrees to radians.

Last edited: 2004

Copyright (c) 2004-2007 by Lode Vandevenne. All rights reserved.