Untitled

mail@pastecode.io avatarunknown
plain_text
a month ago
1.1 kB
2
Indexable
Never
public class ViewModel
{
    private double outerCircleRadius = 167; // Adjust the radius value

    public Point CalculateOuterCirclePosition(double angleInDegrees)
    {
        double angleInRadians = angleInDegrees * Math.PI / 180.0;

        double pointX = outerCircleRadius * Math.Cos(angleInRadians);
        double pointY = outerCircleRadius * Math.Sin(angleInRadians);

        return new Point(pointX, pointY);
    }

    public bool HasReachedOuterBoundary(double canvasLeft, double canvasTop, double angleInDegrees)
    {
        Point rectanglePosition = new Point(canvasLeft, canvasTop);
        Point outerCirclePosition = CalculateOuterCirclePosition(angleInDegrees);

        double distanceSquared = (rectanglePosition.X - outerCirclePosition.X) * (rectanglePosition.X - outerCirclePosition.X) +
                                 (rectanglePosition.Y - outerCirclePosition.Y) * (rectanglePosition.Y - outerCirclePosition.Y);

        double threshold = 1.0; // Adjust this threshold as needed

        return distanceSquared <= threshold;
    }
}