Difference between revisions of "Canvas3D JS Library"
(→Vector Class) |
|||
Line 25: | Line 25: | ||
A Vector basically describes a direction in the form of X, Y, and Z coordinates of a 3D world. Basic 3D math cannot exist without the utilization of spatial coordinates which the Vector Class encapsulates. The Vector Class will have the following members within it: | A Vector basically describes a direction in the form of X, Y, and Z coordinates of a 3D world. Basic 3D math cannot exist without the utilization of spatial coordinates which the Vector Class encapsulates. The Vector Class will have the following members within it: | ||
− | * | + | * Getters |
− | * | + | ** getX() - '''Retrieves the X value''' |
− | * | + | ** getY() - '''Retrieves the Y value''' |
− | * | + | ** getZ() - '''Retrieves the Z value''' |
− | * | + | |
− | * Vector | + | * Setters |
− | * | + | ** set(newX, newY, newZ) - '''This sets new (x, y, z) values to the Vector''' |
− | * | + | ** setX(newX) - '''Takes a number value as the new value for X''' |
− | * | + | ** setY(newY) - '''Takes a number value as the new value for Y''' |
− | * | + | ** setZ(newZ) - '''Takes a number value as the new value for Z''' |
+ | ** setFromVector(vec) - '''Takes a Vector object as the new value for this Vector''' | ||
+ | |||
+ | * Calculations | ||
+ | ** normalize() - '''Unit Normalization''' | ||
+ | ** dot() - '''Calculates the Dot Product. Returns a number''' | ||
+ | ** length() - '''Returns the Length of Vector from (0, 0, 0)''' | ||
+ | ** lengthSq() - '''Returns the Squared value of Length''' | ||
+ | ** cross(vec) - '''Takes a Vector object and computes the Cross Product between the two values. Returns a Vector object that is the cross of the two''' | ||
+ | ** add(vec) - '''Takes a Vector object and adds its values to its own''' | ||
+ | ** subtract(vec) - '''Takes a Vector object and subtracts its values from its own''' | ||
+ | ** multiply(scalar) - '''Takes a number value and multiplies (x, y, z) by it''' | ||
+ | ** divide(scalar) - '''Takes a number value and divides (x, y, z) by it''' | ||
+ | ** isEqual(vec) - '''Takes a Vector object and compares it to its (x, y, z) values. Returns true if they match''' | ||
+ | ** multiplyByQuat(quat) - '''Takes a Quaternion and multiplies its orientation by (x, y, z). It returns a new Vector orientation''' | ||
=== Matrix Class === | === Matrix Class === |
Revision as of 08:36, 30 January 2008
Contents
Introduciton
Under Construction
People Working On This Project
- Catherine Leung
- Mark Paruzel (CodeBot)
- Andrew Smith
Downloads
NOTE: these downloads are mostly meant for in-house testing and not really polished. It may also only work on a specific platform only. please read the note regarding the download.
Andrew's patch - this change to the canvas 3D extension allows the "simple" examples from Vlad's page to work with ati cards. This is intended for Windows only. Model viewer examples do not work yet.
Links
Prototype
Math Operations
Vector Class
A Vector basically describes a direction in the form of X, Y, and Z coordinates of a 3D world. Basic 3D math cannot exist without the utilization of spatial coordinates which the Vector Class encapsulates. The Vector Class will have the following members within it:
- Getters
- getX() - Retrieves the X value
- getY() - Retrieves the Y value
- getZ() - Retrieves the Z value
- Setters
- set(newX, newY, newZ) - This sets new (x, y, z) values to the Vector
- setX(newX) - Takes a number value as the new value for X
- setY(newY) - Takes a number value as the new value for Y
- setZ(newZ) - Takes a number value as the new value for Z
- setFromVector(vec) - Takes a Vector object as the new value for this Vector
- Calculations
- normalize() - Unit Normalization
- dot() - Calculates the Dot Product. Returns a number
- length() - Returns the Length of Vector from (0, 0, 0)
- lengthSq() - Returns the Squared value of Length
- cross(vec) - Takes a Vector object and computes the Cross Product between the two values. Returns a Vector object that is the cross of the two
- add(vec) - Takes a Vector object and adds its values to its own
- subtract(vec) - Takes a Vector object and subtracts its values from its own
- multiply(scalar) - Takes a number value and multiplies (x, y, z) by it
- divide(scalar) - Takes a number value and divides (x, y, z) by it
- isEqual(vec) - Takes a Vector object and compares it to its (x, y, z) values. Returns true if they match
- multiplyByQuat(quat) - Takes a Quaternion and multiplies its orientation by (x, y, z). It returns a new Vector orientation
Matrix Class
A Matrix Class is necessary to provide Matrix operations such as rotation, translation, and scaling to any point in the 3D world. It is composed of a 4x4 matrix of floating point values that can be applied to any Matrix operation. The Matrix Class has the following members:
- void Identity() - Create Identity Matrix
- void Transpose() - Transpose a Matrix
- void Inverse() - Inverse Matrix Values
- float Multiply(Matrix) - Multiplication by Scalar
- float Divide(Matrix) - Division by Scalar
- Matrix Add(Matrix) - Addition of two Matrices
- Matrix Subtract(Matrix) - Subtraction of two Matrices
- Vector Multiply(Vector) - Matrix times a Vector
- Matrix Multiply(Matrix) - Matrix times a Matrix