Created
January 2, 2022 04:53
-
-
Save RustyKnight/be17d1744340f4d8c15373b736745c0f to your computer and use it in GitHub Desktop.
Find point on ellipse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected Point2D pointOnEllipse(double angle, Point2D center, double width, double height) { | |
width = width / 2d; | |
height = height / 2d; | |
angle = Math.toRadians(angle); | |
double t = Math.atan(width * Math.tan(angle) / height); | |
return new Point2D.Double(center.getX() + width * Math.cos(t), center.getY() + height * Math.sin(t)); | |
} | |
protected Point2D pointOnEllipse(double angle, double width, double height) { | |
width = width / 2d; | |
height = height / 2d; | |
angle = Math.toRadians(angle); | |
double t = Math.atan(width * Math.tan(angle) / height); | |
return new Point2D.Double(width * Math.cos(t), height * Math.sin(t)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because it's one of things I'll do once in a while and never remember