public Point IsometricTransform(Perspective perspective) { PointF origin = new PointF((float)(perspective.Parent.ClientSize.Width / 2), (float)(perspective.Parent.ClientSize.Height / 2)); double transX = this.X - perspective.Position.X; double transY = this.Y - perspective.Position.Y; double deltaX = transX - origin.X; double deltaY = transY - origin.Y; double rotX = deltaX * Math.Cos(perspective.Rotation.X) - deltaY * Math.Sin(perspective.Rotation.X) + origin.X; double rotY = deltaY * Math.Cos(perspective.Rotation.X) + deltaX * Math.Sin(perspective.Rotation.X) + origin.Y; deltaY = rotY - origin.Y; double newX = rotX; double newY = deltaY * Math.Cos(perspective.Rotation.Y) + origin.Y - Math.Sin(perspective.Rotation.Y) * (this.Z); //double newY = (rotY * Math.Cos (perspective.Rotation.Y)) + Math.Sin(perspective.Rotation.Y)*(this.Z) + Math.Sin(perspective.Rotation.Y) * origin.Y; return(new Point((int)newX, (int)newY)); }
public void DrawPoint(Graphics g, Brush brush, Perspective p) { Point projectedPoint = this.IsometricTransform(p); g.FillRectangle(brush, new RectangleF(projectedPoint.X - 2, projectedPoint.Y - 2, 5, 5)); }
public void DrawSphere(Graphics g, Perspective p) { DrawPolyhedron(g, p); }