Table of Contents

<Matrix|User's Guide|Quaternion>

Vector

See Javadoc
and Javadoc

Definition

Vectors are used to represent a multitude of things in jME, points in space, vertices in a triangle mesh, normals, etc. These classes (Vector3f in particular) are probably the most used class in jME.

A Vector is defined by an n-tuple of real numbers. V = <V1, V2,…, Vn>.

We have two Vectors (2f and 3f) meaning we have tuples of 2 float values or 3 float values.

Operations

Multiplication by Scalar

A Vector can be multiplied by a scalar value to produce a second Vector with the same proportions as the first. aV = Va = <aV1, aV2,…,aVn>

Addition and Subtraction

Adding or subtracting two Vectors occurs component-wise. That is the first component is added (subtracted) with the first component of the second Vector and so on.

P + Q = <P1+Q1, P2+Q2, …, Pn+Qn>

Magnitude

The magnitude defines the length of a Vector. A Vector of magnitude 1 is unit length.

For example, if V = (x, y, z), the magnitude is the square root of (x2 + y2 + z2).

A Vector can be normalized or made unit length by multiplying the Vector by (1/magnitude).

Dot Products

The dot product of two vectors is defined as: P dot Q = PxQx + PyQy + PzQz

Using the dot product allows us to determine how closely two Vectors are pointing to the same point. If the dot product is negative they are facing in relatively opposite directions, while postive tells us they are pointing in the relative same direction.

If the dot product is 0 then the two Vectors are orthogonal or 90 degrees off.

Cross Product

The Cross Product of two Vectors returns a third Vector that is prependicular to the two Vectors. This is very useful for calculating surface normals.

P X Q = <PyQz - PzQy, PzQx - PxQz, PxQy - PyQx>

jME Class

Vector3f and Vector2f store their values (x, y, z) and (x, y) respectively as floats. Most methods are straight forward, and I will leave documentation to the Javadoc.

<Matrix|User's Guide|Quaternion>


/var/www/wiki/data/pages/vector.txt · Last modified: 2009/07/28 18:44 (external edit)  
Recent changes · Show pagesource · Login

Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

subscribe to jME latest jme headlines


site design by bleedcrimson designs © 2008