Package physics.collision.shape
Class Circle
java.lang.Object
physics.collision.shape.PrimitiveShape
physics.collision.shape.Circle
The shape implementation of a circle.
- Since:
- 19.06.2021
- Author:
- Juyas
-
Field Summary
Fields inherited from class physics.collision.shape.PrimitiveShape
absoluteCentroid, absolutes, boundingSphere, faces, relativeCentroid, relatives, vertices
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
adjust()
Will be called byPrimitiveShape.setPosition(Vector2f)
after the new position was set.boolean
intersection
(Circle circle) Check intersection between two circles efficiently without using square roots.rayCast
(org.joml.Vector2f start, org.joml.Vector2f rayDirection, float maxLength) Calculate a raycast against this circle using absolute coordinates.org.joml.Vector2f
supportPoint
(org.joml.Vector2f v) According to GJKSM this method is supposed to calculate the point of the shape, that is most in direction of v.Methods inherited from class physics.collision.shape.PrimitiveShape
boundingSphere, centroid, faces, getAbsolutePoints, init, initSphere, position, rotateShape, setPosition, setPosition, type, vertices
-
Constructor Details
-
Circle
public Circle(org.joml.Vector2f relativeCenter, float radius)
-
-
Method Details
-
adjust
public void adjust()Description copied from class:PrimitiveShape
Will be called byPrimitiveShape.setPosition(Vector2f)
after the new position was set. Used to recalculate the absolute coordinates.- Overrides:
adjust
in classPrimitiveShape
-
supportPoint
public org.joml.Vector2f supportPoint(org.joml.Vector2f v) Description copied from class:PrimitiveShape
According to GJKSM this method is supposed to calculate the point of the shape, that is most in direction of v. The general rule is, the more primitive the shape is, the more efficient this method can be. This method may be described as max{v*x,x element of Shape} for any complex shape.- Overrides:
supportPoint
in classPrimitiveShape
- Parameters:
v
- the direction- Returns:
- the point of the shape that is most in the direction of v
-
intersection
Check intersection between two circles efficiently without using square roots. Will only produce wrong results originated in missing precision in floating point numbers.- Parameters:
circle
- the circle to compare to- Returns:
- true if the given circle intersects with this one
-
rayCast
public RayCastResult rayCast(org.joml.Vector2f start, org.joml.Vector2f rayDirection, float maxLength) Calculate a raycast against this circle using absolute coordinates.- Parameters:
start
- the starting point of the raycastrayDirection
- the direction of the ray, it doesnt have to be normalized, it will be by the methodmaxLength
- the max length of ray, if it can't hit within this range, it doesnt hit- Returns:
- the result of the raycast
-