Ejemplo n.º 1
0
 public void DotWithVector_WorksInBothDirections()
 {
     var vec = new Vector(4.5f, 2.7f);
     var prod1 = Line1 * vec;
     var prod2 = vec * Line1;
     Assert.IsTrue(prod1 == prod2);
 }
Ejemplo n.º 2
0
 public void AdditionWithVector_WorksInBothDirections()
 {
     var vec = new Vector(3.2f, 5.3f);
     var sum1 = Line1 + vec;
     var sum2 = vec + Line1;
     Assert.IsTrue(sum1 == sum2);
 }
Ejemplo n.º 3
0
Archivo: Line.cs Proyecto: kgroat/Valor
 public Line(Vector start, Vector end)
 {
     this.Start = start;
     this.End = end;
 }
Ejemplo n.º 4
0
Archivo: Line.cs Proyecto: kgroat/Valor
 public virtual Vector PointOfIntersection2D(Line intersector)
 {
     var p = new Vector(-intersector.Y, intersector.X);
     var h = ((-this.Start + intersector.Start) * p) / (this * p);
     return this.Start + this * h;
 }
Ejemplo n.º 5
0
Archivo: Line.cs Proyecto: kgroat/Valor
 public virtual Line PerpendicularThrough(Vector point)
 {
     throw new NotImplementedException("Not yet implemented.");
 }
Ejemplo n.º 6
0
Archivo: Line.cs Proyecto: kgroat/Valor
 public virtual bool Intersects2D(Line intersector)
 {
     bool intersection = false;
     var p = new Vector(-intersector.Y, intersector.X);
     var h = ((-this.Start + intersector.Start) * p) / (this * p);
     intersection = h >= 0 && h <= 1;
     if (intersection)
     {
         p = new Vector(-this.Y, this.X);
         h = ((-intersector.Start + this.Start) * p) / (intersector * p);
         intersection = h >= 0 && h <= 1;
     }
     return intersection;
 }
Ejemplo n.º 7
0
 internal Vector Clamp(Vector minValues, Vector maxValues, out int bx, out int by, out int bz)
 {
     float nx = X, ny = Y, nz = Z;
     bx = by = bz = 0;
     if (X < minValues.X)
     {
         nx = minValues.X;
         bx = -1;
     }
     else if (X > maxValues.X)
     {
         nx = maxValues.X;
         bx = 1;
     }
     if (Y < minValues.Y)
     {
         ny = minValues.Y;
         by = -1;
     }
     else if (Y > maxValues.Y)
     {
         ny = maxValues.Y;
         by = 1;
     }
     if (Z < minValues.Z)
     {
         nz = minValues.Z;
         bz = -1;
     }
     else if (Z > maxValues.Z)
     {
         nz = maxValues.Z;
         bz = 1;
     }
     return new Vector(nx, ny, nz);
 }
Ejemplo n.º 8
0
 public Vector Subtract(Vector subtrahend)
 {
     return new Vector(this.X - subtrahend.X, this.Y - subtrahend.Y);
 }
Ejemplo n.º 9
0
 public bool Equals(Vector other)
 {
     if (other != null)
     {
         return this.GetHashCode() == other.GetHashCode();
     }
     return false;
 }
Ejemplo n.º 10
0
 public float Dot(Vector other)
 {
     return this.X * other.X + this.Y * other.Y + this.Z * other.Z;
 }
Ejemplo n.º 11
0
 public Vector Cross(Vector other)
 {
     var u = this;
     var v = other;
     return new Vector(
         this.Y * other.Z - this.Z * other.Y,
         this.Z * other.X - this.X * other.Z,
         this.X * other.Y - this.Y * other.X);
 }
Ejemplo n.º 12
0
 public Vector Add(Vector addend)
 {
     return new Vector(this.X + addend.X, this.Y + addend.Y);
 }
Ejemplo n.º 13
0
 public void SubtractionWithVector_WorksInBothDirections()
 {
     var vec = new Vector(3.5f, 2.3f);
     var diff1 = Line1 - vec;
     var diff2 = vec - Line1;
     Assert.IsTrue(diff1 == -diff2);
 }
Ejemplo n.º 14
0
Archivo: Ship.cs Proyecto: kgroat/Valor
 public void Render(Graphics g, Vector pos)
 {
     ToRender.Render(g, pos);
 }
Ejemplo n.º 15
0
 public void EmptyConstructor_ReturnsZeroVector()
 {
     var zero = new Vector();
     Assert.IsTrue(zero.X == 0 && zero.Y == 0 && zero.Length == 0);
 }
Ejemplo n.º 16
0
 public void Setup()
 {
     this.Vector1 = new Vector(2.5f, 3.6f);
     this.Vector2 = new Vector(1.3f, 4.2f);
 }