
398
Chapter 17: Controlling the 3D World
Vector methods
Use these methods to work with vectors:
Vector binary operations
Use these syntaxes to perform additional vector math calculations:
Note:
JavaScript does not support these operations for vector objects. In JavaScript, you must write
the code to perform the vector math calculations using the vectors’
x
,
y
, and
z
coordinates.
Method
Description
Returns
normalize()
Normalizes the vector by modifying it into a unit vector of
length 1. This is done by dividing each component of the
vector by the vector’s original length. That original length
is the square root of the sum of the squares of each
component.
Nothing. Vector is
modified.
get
Normalized()
Returns a normalized version of the vector.
A new vector object.
dot(
vector2
)
Returns the dot (inner) product of the first vector and the
second vector (
vector2
). If both vectors are of unit
length, the result is the cosine of the angle between the
two vectors.
Dot product of the
two vectors.
angleBetween
(
vector2
)
Returns the angle between
vector
and
vector2
, in
degrees.
Value of the angle in
degrees.
cross(
vector2
)
or
crossProduct
(
vector2
)
or
perpendicular
To(
vector2
)
Returns a vector perpendicular to the original vector and
to
vector2
.
A new vector object.
distanceTo
(
vector2
)
Returns the distance between
vector
and
vector2
. If
these vectors represent positions in the 3D world, this is
the distance between them.
Floating-point value
of distance.
duplicate()
A copy of the vector.
A new vector object.
Operator
Description
Returns
vvector2
Returns a new vector equaling
vector1
+vector2
for
x
equaling 1 through 3.
A new vector object
vector1 -vector2
Returns a new vector equaling
vector1 -vector2
for
x
equaling 1 through 3.
A new vector object
vector1*
vector2
Returns the product of the two vectors.
A floating-point value
vector1/vector2
Not supported.
0
vector2*scalar
Returns a new vector equaling
vector2 * scalar
for
x
equaling 1 through 3.
A new vector object
Summary of Contents for DIRECTOR MX 2004-USING DIRECTOR
Page 1: ...DIRECTOR MX 2004 Using Director...
Page 16: ...16 Chapter 1 Introduction...
Page 82: ...82 Chapter 3 Sprites...
Page 98: ...98 Chapter 4 Animation...
Page 134: ...134 Chapter 5 Bitmaps...
Page 242: ...242 Chapter 10 Sound and Synchronization...
Page 274: ...274 Chapter 11 Using Digital Video...
Page 290: ...290 Chapter 12 Behaviors...
Page 302: ...302 Chapter 13 Navigation and User Interaction...
Page 334: ...334 Chapter 15 The 3D Cast Member 3D Text and 3D Behaviors...
Page 392: ...392 Chapter 16 Working with Models and Model Resources...
Page 418: ...418 Chapter 18 Movies in a Window...
Page 446: ...446 Chapter 22 Managing and Testing Director Projects...