OpenLayer Offline Manual

OpenLayer | Vec2D Vec2D
Vec2D( | float x = 0.0, float y = 0.0 )
Constructs a new vector with the specified components. The 2D vector class holds the x and y values of the vector which can be directly accessed from the object. Several common operators have been overloaded for the vector class. These are sum, subtraction, multiplication, division, normalization (~ -operator) and the dot product (Vec2D * Vec2D). See the exaples to see how to use them. Examples // Create a new vector called theVector with x = 15.0 and y = 20.0 // Vec2D theVector( 15.0, 20.0 ); // Get the x component of the vector // float x = theVector.x; // Get the y component of the vector // float y = theVector.y; // Create a new vector called secondVector with x = -50.0 and y = 100.0 // Vec2D secondVector( -50.0, 100.0 ); // Get a vector sum of theVector and secondVector // Vec2D sum = theVector + secondVector; // Get a vector with 5 times the magnitude of secondVector // Vec2D biggerVector = 5.0 * secondVector; // Increase biggerVector by x = 40, y = -30.5 // biggerVector += Vec2D( 40.0, -30.5 ); // Get a normalized copy of biggerVector // // (a vector which has the same direction as biggerVector but magnitude of 1.0) // Vec2D normalizedBigger = ~biggerVector; // Get a dot product between two vectors // float dotProduct = theVector * secondVector; Member functions
GetMagnitude | Returns the magnitude (length) of the vector
GetAngle | Returns the angle of the vector
Normalized | Returns a normalized copy of the vector
Advanced functions
GetMagnitudeSquared | Returns the squared magnitude of the vector
Back to the main page of the manual Questions about Vec2D? Click here.