- Object
-
- AbstractShape
-
- Segment
-
- Link
-
- All Implemented Interfaces:
DataContainer
,Convex
,Rotatable
,Shape
,Transformable
,Translatable
,Wound
public class Link extends Segment implements Convex, Wound, Shape, Transformable, DataContainer
This class is a specialization of theSegment
class that provides smooth sliding across a chain of line segments. This is achieved by storing the connectivity information between the links. With this, a correction process is performed to avoid the 'internal edge' problem.A
Link
is an infinitely thin line segment and will behave like theSegment
class in collision response.Like the
Segment
class, this class can be locally rotated or translated. However, doing so will also translate/rotated the next or previousLink
s.For ease of use, it's recommended to use the Geometry class to create chains of
Link
s.- Since:
- 3.2.2
- Version:
- 3.2.2
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Link
getNext()
Returns the next link in the chain.Vector2
getPoint0()
Returns the last vertex of the previous segment.Vector2
getPoint3()
Returns the first vertex of the next segment.Link
getPrevious()
Returns the previous link in the chain.void
rotate(double theta, double x, double y)
Rotates the object about the given coordinates.void
setNext(Link next)
Sets the next link in the chain.void
setPrevious(Link previous)
Sets the previous link in the chain.String
toString()
void
translate(double x, double y)
Translates the object the given amounts in the respective directions.-
Methods inherited from class Segment
computeAABB, contains, contains, createAABB, createMass, getAxes, getFarthestFeature, getFarthestFeature, getFarthestPoint, getFarthestPoint, getFoci, getLength, getLineIntersection, getLineIntersection, getLocation, getNormalIterator, getNormals, getPoint1, getPoint2, getPointOnLineClosestToPoint, getPointOnLineClosestToPoint, getPointOnSegmentClosestToPoint, getPointOnSegmentClosestToPoint, getRadius, getSegmentIntersection, getSegmentIntersection, getVertexIterator, getVertices, project, rotate
-
Methods inherited from class AbstractShape
computeAABB, contains, createAABB, getCenter, getRadius, getUserData, project, rotate, rotate, rotate, rotate, rotateAboutCenter, setUserData, translate
-
Methods inherited from interface Convex
getAxes, getFarthestFeature, getFarthestPoint, getFoci
-
Methods inherited from interface DataContainer
getUserData, setUserData
-
Methods inherited from interface Shape
computeAABB, computeAABB, contains, contains, createAABB, createAABB, createMass, getCenter, getRadius, getRadius, project, project, rotateAboutCenter
-
Methods inherited from interface Translatable
translate
-
Methods inherited from interface Wound
getNormalIterator, getNormals, getVertexIterator, getVertices
-
-
-
-
Method Detail
-
getPoint0
public Vector2 getPoint0()
Returns the last vertex of the previous segment.- Returns:
- Vector2
-
getPoint3
public Vector2 getPoint3()
Returns the first vertex of the next segment.- Returns:
- Vector2
-
setNext
public void setNext(Link next)
Sets the next link in the chain.This method will also:
- Unlink the current next (if applicable) and this link
- Link the given next and this link
- Parameters:
next
- the next link
-
setPrevious
public void setPrevious(Link previous)
Sets the previous link in the chain.This method will also:
- Unlink the current previous (if applicable) and this link
- Link the given previous and this link
- Parameters:
previous
- the previous link
-
rotate
public final void rotate(double theta, double x, double y)
Description copied from interface:Rotatable
Rotates the object about the given coordinates.- Specified by:
rotate
in interfaceRotatable
- Overrides:
rotate
in classAbstractShape
- Parameters:
theta
- the angle of rotation in radiansx
- the x coordinate to rotate abouty
- the y coordinate to rotate about
-
translate
public final void translate(double x, double y)
Description copied from interface:Translatable
Translates the object the given amounts in the respective directions.- Specified by:
translate
in interfaceTranslatable
- Overrides:
translate
in classSegment
- Parameters:
x
- the translation in the x directiony
- the translation in the y direction
-
-