Exemplo n.º 1
0
 /// <summary>
 ///     Returns the dot product of this vector and the given vector.
 /// </summary>
 /// <param name="v2">Second vector to get dot product from.</param>
 /// <returns>The dot product of this vector and the given vector.</returns>
 public float DotProduct(Vector v2)
 {
     return (_x * v2._x) + (_y * v2._y) + (_z * v2._z);
 }
Exemplo n.º 2
0
 /// <summary>
 ///     Returns the projection of this vector onto a given vector.
 /// </summary>
 /// <param name="v2">Second vector to project onto.</param>
 /// <returns>Projection of this vector to the given vector.</returns>
 public Vector Project(Vector v2)
 {
     float dp = DotProduct(v2);
     return new Vector((dp / ((v2._x * v2._x) + (v2._y * v2._y) + (v2._z * v2._z))) * v2._x,
                       (dp / ((v2._x * v2._x) + (v2._y * v2._y) + (v2._z * v2._z))) * v2._y,
                       (dp / ((v2._x * v2._x) + (v2._y * v2._y) + (v2._z * v2._z))) * v2._z);
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Returns the cross product of this vector and the given vector.
 /// </summary>
 /// <param name="v2">Second vector to get cross product from.</param>
 /// <returns>The cross product of this vector and the given vector.</returns>
 public Vector CrossProduct(Vector v2)
 {
     return new Vector((_y * v2._z) - (_z * v2._y), (_z * v2._x) - (_x * v2._z), (_x * v2._y) - (_y * v2._x));
 }