User Tools

Site Tools


2d_vector

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

2d_vector [2022/04/30 20:12] (current)
max created
Line 1: Line 1:
 +====== Vector2 ======
  
 +Vector2 consists two floats, ''x'' and ''y''
 +Similar to Matrices, Vectors also have two methods of accessing their variables.
 +
 +Namely, you can access them directly, or using the ''[]'' operator, similar to an array. 
 +
 +The following example uses both methods:
 +<code c>
 +float Vector2::Dot(const Vector2& other) const {
 + return asArray[0] * other.x + asArray[1] * other.y;
 +}
 +</code>
 +
 +Vector2 also features the following utility functions:
 +  * ''Dot''
 +  * ''Magnitude''
 +  * ''MagnitudeFast'', which omits the square root function call, providing a very helpful speedboost.
 +  * ''Distance''
 +  * ''Normalize''
 +  * ''Angle'', returns the angle between this and another Vector2
 +
 +The following utility functions return *new* Vector2 objects:
 +  * ''Project''
 +  * ''Perpendicular''
 +  * ''Reflection''
 +  * ''Clamp'', clamps the vector between a given min and a max. 
2d_vector.txt ยท Last modified: 2022/04/30 20:12 by max