Package org.lazywizard.lazylib
Class EllipseUtils
Object
EllipseUtils
Contains methods for dealing with ellipses. Since these methods are only
used in very specific cases, they have been moved into their own class to
reduce clutter in the main library classes.
- Since:
- 1.9
- Author:
- LazyWizard
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector2fgetPointOnEllipse(Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset, float angle) Returns a point along the circumference of an ellipse at the given angle and facing.static Vector2fgetRandomPointInEllipse(Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset) Returns a random point inside of an ellipse with uniform distribution.static Vector2fgetRandomPointOnEllipse(Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset) Returns a random point along the circumference of an ellipse.static booleanisPointWithinEllipse(Vector2f point, Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset) Checks whether a point is on or within the bounds of an ellipse.
-
Method Details
-
getPointOnEllipse
public static Vector2f getPointOnEllipse(@Nullable Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset, float angle) Returns a point along the circumference of an ellipse at the given angle and facing.- Parameters:
ellipseCenter- The center point of the ellipse (can be null for a 0, 0 origin).ellipseWidth- The width (size on unrotated x-axis) of the ellipse.ellipseHeight- The height (size on unrotated y-axis) of the ellipse.ellipseAngleOffset- How much to rotate the ellipse from its original axis, in degrees.angle- The angle, in degrees, to get the point at.- Returns:
- A
Vector2fat [@code angle} degrees along the circumference of the given ellipse. - Since:
- 1.9
-
getRandomPointOnEllipse
public static Vector2f getRandomPointOnEllipse(@Nullable Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset) Returns a random point along the circumference of an ellipse.- Parameters:
ellipseCenter- The center point of the ellipse (can be null for a 0, 0 origin).ellipseWidth- The width (size on unrotated x-axis) of the ellipse.ellipseHeight- The height (size on unrotated y-axis) of the ellipse.ellipseAngleOffset- How much to rotate the ellipse from its original axis, in degrees.- Returns:
- A random point along the circumference of the given ellipse.
- Since:
- 1.9
- See Also:
-
getRandomPointInEllipse
public static Vector2f getRandomPointInEllipse(@Nullable Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset) Returns a random point inside of an ellipse with uniform distribution.- Parameters:
ellipseCenter- The center point of the ellipse (can be null for a 0, 0 origin).ellipseWidth- The width (size on unrotated x-axis) of the ellipse.ellipseHeight- The height (size on unrotated y-axis) of the ellipse.ellipseAngleOffset- How much to rotate the ellipse from its original axis, in degrees.- Returns:
- A random point inside of the given ellipse.
- Since:
- 2.0
-
isPointWithinEllipse
public static boolean isPointWithinEllipse(Vector2f point, @Nullable Vector2f ellipseCenter, float ellipseWidth, float ellipseHeight, float ellipseAngleOffset) Checks whether a point is on or within the bounds of an ellipse.- Parameters:
point- TheVector2fto check.ellipseCenter- The center point of the ellipse (can be null for a 0, 0 origin).ellipseWidth- The width (size on unrotated x-axis) of the ellipse.ellipseHeight- The height (size on unrotated y-axis) of the ellipse.ellipseAngleOffset- How much to rotate the ellipse from its original axis, in degrees.- Returns:
trueifpointis on or within the ellipse,falseotherwise.- Since:
- 1.9
-