Vec2D 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
Questions about Vec2D? Click here. |