new V3()
 Source:
Members
(static, constant) forward
A constant the defines the forward vector. WARNING: be extremly careful not to modify the values of this vector, because this will cause some matrix functions to not fuction properly.
 Source:
(static, constant) up
A constant the defines the up vector. WARNING: be extremly careful not to modify the values of this vector, because this will cause some matrix functions, like SQR.Matrix44#lookAt to not fuction properly.
 Source:
Methods
add(a, bopt)
Sets this vector to the sum of a and b.
Parameters:
Name  Type  Attributes  Description 

a 
SQR.V3  
b 
SQR.V3 
<optional> 
if omitted the current vector is used, which basically means that a is added to current vector. 
 Source:
Example
a.add(b, c); // a = b + c
a.add(a, b); // a += b
a.add(b); // alt a += b
a.add(a, b).add(a, c); // = a + b + c
addNormal()
Use this for caculating pervertex normals.
A normal from each contributing face can be added here.
When all the normals are added, a vector that is the sum of them all
is available as this.normal
property. The prevertex normal can be caluculated
by normalizing this vector.
 Source:
clone() → {SQR.V3}
Creates and returns a copy of this vector. Be careful with this method, because it creates a new object. Calling this function repeatedly in a rendering loop can have an adverce impact on performance.
 Source:
Returns:
a new vector that is a copy of this vector
 Type
 SQR.V3
copyFrom(p)
Copies values from vector p into this vector
Parameters:
Name  Type  Description 

p 
SQR.V2  SQR.V3  vector to copy the values from if available, otherwise defaults to zero 
 Source:
copyTo(p)
Copies values from this vector into the p vector
Parameters:
Name  Type  Description 

p 
SQR.V2  SQR.V3  vector to copy the values to 
 Source:
cross()
Sets this vector to the result of a crossproduct of a and b (a x b
).
 Source:
isZero()
Shorthand to check if this vector is a zero vector (i.e. all compoments are very small or equal to 0) The values are compared against SQR.EPSILON
 Source:
mag() → {Number}
Return the length (magnitude) of this vector
 Source:
Returns:
the length of this vector
 Type
 Number
magsq()
Returns the squared length of this vector. This can be useful to optimize some calculations, since
the actual length requires a squareroot operation (Math.sqrt()
)
which can be slow if used on many vectors.
 Source:
mul(s)
Multiples this vector by a scalar. This function can be used in conjunction with SQR.V3#norm to set the vector to a given length `v.norm().mul(10)1 yields a vector of length 10.
Parameters:
Name  Type  Description 

s 
Number  the value to multiply the the vector by. 
 Source:
neg()
Negates this vector.
 Source:
norm()
Normalizes this vector, i.e. sets its length (magnitude) to 1.
 Source:
resetNormal()
This is used to reset the normal to 0,0,0.
 Source:
set(x, y, z, w)
Sets the vector compoment to values. Note that this class has actually 4 not 3 compoments.
Parameters:
Name  Type  Description 

x 
the value of the x compoment 

y 
the value of the y compoment 

z 
the value of the z compoment 

w 
the value of the homogeneous coordinate, defaults to 1 and leave it that way unless you really know what ypu are doing. 
 Source:
sub(a, b)
a.sub(b, a) > a = from a to b
Parameters:
Name  Type  Description 

a 

b 
 Source:
toScreenSpace(wopt, hopt)
Assuming the vector was projected using the SQR.ProjectionMatrix, use this to calculate it's screen space. (useful for software rendering, ex. on canvas 2d)
Parameters:
Name  Type  Attributes  Description 

w 
Number 
<optional> 
the width of the screen (defaults to 
h 
Number 
<optional> 
the height of the screen (defaults to 
 Source:
(static) dot() → {Number}
Returns the dot product of a nd b (a . b
).
 Source:
Returns:
result of a . b
 Type
 Number