Exemplo n.º 1
0
 /// <summary>
 /// Distance from the vector to another.
 /// </summary>
 /// <param name="b">The other vector.</param>
 /// <returns></returns>
 public float dist(V2 b) => (this - b).len;
Exemplo n.º 2
0
 /// <summary>
 /// Makes a new 3D vector from a 2D vector.
 /// </summary>
 /// <param name="xy">XY components.</param>
 /// <param name="z">Z component.</param>
 public V3(V2 xy, float z)
 {
     this.x = xy.x;
     this.y = xy.y;
     this.z = z;
 }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the dot product of two 2D vectors.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 /// <returns></returns>
 public static float dot(V2 a, V2 b) => (a * b).sum;
Exemplo n.º 4
0
 /// <summary>
 /// Gets the distance between two 2D vectors.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 /// <returns></returns>
 public static float dist(V2 a, V2 b) => (b - a).len;
Exemplo n.º 5
0
 /// <summary>
 /// Gets the angle between two 2D vectors.
 /// </summary>
 /// <param name="a">First vector.</param>
 /// <param name="b">Second vector.</param>
 /// <returns></returns>
 public static float angle(V2 a, V2 b) => ((a.unit * b.unit).sum + 1f) / PI2F;