vectorMath, crossProduct, scalarProduct

 From:  bemfarmer
4951.1 
Michael, does the following code appear ok for manipulation of vectors in MoI? Is there a better way?

In the script that is being created, I'm using your dot product code, and length and normalize from your bisector script.
Needed is cross product of 2 vectors, and also scalar product.

// Michael's MoI bisector script has the needed code for dot product, length, and
// normalize. Reference book: Geometric Tools for Computer Graphics. Section 4.4
// of the book, page 117, shows the dot product code. Page 119 shows the cross
// product code, which is similarly converted to MoI type javascript, using v0
// instead of the u1 vector used in the book. Note that v0 and v1 are Vectors,
// and v0.x, v0.y, v0.z, v1.x, v1.y, and v1.z, are the x, y, and z parts of the vectors.
// (crossproduct creates the new "pseudo" vector, which is still a vector.)
// Scalar formula is on page 115.
// Elsewhere I've read that: "The individual components of a 3D vector can be accessed through its x, y and z member variables."

function crossProduct( v0, v1, startpt )
{
var vcx = (v0.y * v1.z) - (v0.z * v1.y);
var vcy = (v0.z * v1.x) - (v0.x * v1.z);
var vcz = (v0.x * v1.y) - (v0.y * v1.x);
var vcross_endpt = moi.vectorMath.createPoint( vcx, vcy, vcz );
var vcross = moi.vectorMath.makeVector( startpt, vcross_endpt);
return vcross;
}

function scalarProduct( v0, a, startpt )
{
var vcx = v0.x * a;
var vcy = v0.y * a;
var vcz = v0.z * a;
var vscalar-endpt = moi.vectorMath.createPoint( vcx, vcy, vcz );
var vscalar = moi.vectorMath.makeVector( startpt, vscalar-endpt);
return vscalar;
}

vectorMath.makeVector is not in the documentation.
Are there any other undocumented vectorMath methods?
The difference between Points and Vectors, and their display, is confusing to me.
I'm thinking Points are displayed as the endpoints of vectors, from some origin, and vectors are displayed as start and end points...

Thank you.

EDITED: 21 Feb 2012 by BEMFARMER