void SetSideLengths(PointD startPoint, PointD endPoint) { PointD rightPoint = new PointD(endPoint.X, startPoint.Y); oppLen = rightPoint.DistanceTo(endPoint); hypLen = startPoint.DistanceTo(endPoint); adjLen = startPoint.DistanceTo(rightPoint); }
void _SetEndPoint(double ex, double ey) { aimPos.Set(ex, ey); rightPos.Set(aimPos.X, originPos.Y); oppLen = rightPos.DistanceTo(aimPos); hypLen = originPos.DistanceTo(aimPos); adjLen = originPos.DistanceTo(rightPos); SetRotation(); // endPoint is for testing. endPoint should match aimPos if calculations are correct. //endPoint.X = originPos.X + hypLen * Math.Cos(rotation); //endPoint.Y = originPos.Y + hypLen * Math.Sin(rotation); endPointSet = true; }
protected bool InCircle(double x, double y) { if (position.DistanceTo(x, y) < radius) { return(true); } return(false); }
// Not tested in this location yet, but this is code from Trajectory03 public void Set(PointD startPoint, PointD endPoint) { bool north, south; double anglePreRotation = 0; //double rot = 0; double oppLen = 0, hypLen = 0; PointD rightPoint = new PointD(endPoint.X, startPoint.Y); oppLen = rightPoint.DistanceTo(endPoint); hypLen = startPoint.DistanceTo(endPoint); north = south = false; if (endPoint.Y < startPoint.Y) { north = true; } if (endPoint.Y > startPoint.Y) { south = true; } anglePreRotation = Math.Asin(oppLen / hypLen); // north if (endPoint.X == startPoint.X && north) { rot = (3 * Math.PI) / 2; return; } // south if (endPoint.X == startPoint.X && south) { rot = (Math.PI) / 2; return; } // east if (endPoint.X > startPoint.X && endPoint.Y == startPoint.Y) { rot = 0; return; } // west if (endPoint.X < startPoint.X && endPoint.Y == startPoint.Y) { rot = Math.PI; return; } // northwest if (endPoint.X > startPoint.X && north) { rot = Math.PI * 2 - anglePreRotation; return; } //northeast if (endPoint.X < startPoint.X && north) { rot = Math.PI + anglePreRotation; return; } // southwest if (endPoint.X > startPoint.X && south) { rot = anglePreRotation; return; } // southeast if (endPoint.X < startPoint.X && south) { rot = Math.PI - anglePreRotation; return; } }