コード例 #1
0
 // Get the distance from this Vector2D to the other one squared.
 public float DistToSqr(SourceVector2 vOther)
 {
     return(new SourceVector2(
                ix: x - vOther.x,
                iy: y - vOther.y
                ).LengthSqr());
 }
コード例 #2
0
 public SourceVector2 Max(SourceVector2 vOther)
 {
     return(new SourceVector2(x > vOther.x ? x : vOther.x,
                              y > vOther.y ? y : vOther.y));
 }
コード例 #3
0
 // Dot product.
 public float Dot(SourceVector2 vOther) => (x * vOther.x + y * vOther.y);
コード例 #4
0
 // Returns a SourceVector2 with the min or max in X, Y, and Z.
 public SourceVector2 Min(SourceVector2 vOther)
 {
     return(new SourceVector2(x < vOther.x ? x : vOther.x,
                              y < vOther.y ? y : vOther.y));
 }
コード例 #5
0
 // Multiply, add, and assign to this (ie: *this = a + b * scalar). This
 // is about 12% faster than the actual Vector2D equation (because it's done per-component
 // rather than per-Vector2D).
 public void MulAdd(SourceVector2 a, SourceVector2 b, float scalar)
 {
     x = a.x + b.x * scalar;
     y = a.y + b.y * scalar;
 }