Beispiel #1
0
 public LineSegment(double magnitude, Angle angle, Vector midpoint)
 {
     this.magnitude = magnitude;
     this.angle = angle;
     this.StartingPos = new Vector( midpoint.GetX() - .5*magnitude *Math.Cos(angle.InRadians()),
                         midpoint.GetY() - .5*magnitude * Math.Sin(angle.InRadians()));
     this.EndingPos = new Vector(midpoint.GetX() + .5 * magnitude * Math.Cos(angle.InRadians()),
                         midpoint.GetY() + .5 * magnitude * Math.Sin(angle.InRadians()));
     components.Add(EndingPos.GetX() - StartingPos.GetX());
     components.Add(EndingPos.GetY() - StartingPos.GetY());
 }
Beispiel #2
0
 public LineSegment(Vector start, Angle angle, double length)
 {
     this.StartingPos = start;
     this.magnitude = length;
     this.angle = angle;
     components.Add(magnitude * Math.Cos(angle.InRadians()));
     components.Add(magnitude * Math.Sin(angle.InRadians()));
     this.EndingPos = new Vector(StartingPos.GetX() + XComponent(),
                                 StartingPos.GetY() + YComponent());
     this.slope = Slope();
 }
Beispiel #3
0
 public LineSegment(Vector start, Vector end)
 {
     if (start.NumberOfDimensions != end.NumberOfDimensions)
         throw new Exception("Inconsistent dimensionalities");
     this.NumberOfDimensions = start.NumberOfDimensions;
     this.StartingPos = start;
     this.EndingPos = end;
     components.Add(EndingPos.GetX() - StartingPos.GetX());
     components.Add(EndingPos.GetY() - StartingPos.GetY());
     this.angle = Angle();
     this.slope = Slope();
     this.magnitude = Magnitude();
 }
Beispiel #4
0
 public IEnumerable<List<double>> GetComponentsForEachDimension(Vector b)
 {
     if (this.NumberOfDimensions != b.NumberOfDimensions)
         throw new Exception("Inconsistent dimensionalities");
     for (int i = 0; i < this.NumberOfDimensions; i++) {
         List<double> componentsToReturn = new List<double>();
         if (i == 0) {
             componentsToReturn.Add(this.GetX());
             componentsToReturn.Add(b.GetX());
         }
         if (i == 1) {
             componentsToReturn.Add(this.GetY());
             componentsToReturn.Add(b.GetY());
         }
         if (i == 2) {
             componentsToReturn.Add(this.GetZ());
             componentsToReturn.Add(b.GetZ());
         }
         yield return componentsToReturn;
     }
 }
Beispiel #5
0
 public Vector RotateAbout(Vector CenterPoint, Angle angle)
 {
     double startingX = this.GetX() - CenterPoint.GetX();
     double startingY = this.GetY() - CenterPoint.GetY();
     double xPos = (startingX) * Math.Cos(angle.InRadians()) - (startingY) * Math.Sin(angle.InRadians());
     double yPos = (startingX) * Math.Sin(angle.InRadians()) + (startingY) * Math.Cos(angle.InRadians());
     return new Vector(xPos + CenterPoint.GetX(), yPos + CenterPoint.GetY());
 }
 public static bool ContainsPoint(this Rectangle rect, Vector point)
 {
     if (point.GetX() < rect.X || point.GetX() > rect.Right || point.GetY() < rect.Top || point.GetY() > rect.Bottom)
         return false;
     else return true;
 }
 public FourBorders(Vector topLeft, Vector bottomRight)
 {
     BoundingRectangle = new Rectangle((int)topLeft.GetX(), (int)topLeft.GetY(), (int)bottomRight.GetX(), (int)bottomRight.GetY());
     CenterPoint = null;
     Geometry = null;
     this.DrawMe = false;
 }
 public Walls(Vector bottomLeft, Vector topRight)
 {
     DrawMe = false;
     BoundingRectangle = new System.Windows.Rect(bottomLeft.GetX(), bottomLeft.GetY(), topRight.GetX(), topRight.GetY());
     Geometry = new LineGeometry();
     CenterPoint = new Vector((bottomLeft.GetX() + topRight.GetX()) / 2, (bottomLeft.GetY() + topRight.GetY()) / 2);
 }