Class ConvexObject
- java.lang.Object
-
- org.scilab.forge.scirenderer.implementation.g2d.motor.AbstractDrawable3DObject
-
- org.scilab.forge.scirenderer.implementation.g2d.motor.ConvexObject
-
- Direct Known Subclasses:
Segment
,SpritedRectangle
,Triangle
public abstract class ConvexObject extends AbstractDrawable3DObject
- Author:
- Calixte DENIZET Class to represent a convex object. Collision and relative positions of convexs object are relatively easy to determinate. About the method isBehind, it could be interesting to use the algorithm of Chung-Wang.
-
-
Constructor Summary
Constructors Constructor Description ConvexObject(Vector3d[] vertices, java.awt.Color[] colors)
Default constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addArea(ConvexObject co)
boolean
areCoplanar(ConvexObject o)
Test the coplanarity of two objectsabstract java.util.List<ConvexObject>
breakObject(ConvexObject o)
Abstract method Break this ConvexObject against the ConvexObject oabstract java.util.List<ConvexObject>
breakObject(Vector4d v)
Abstract method Break this ConvexObject against a planeprotected int
check(ConvexObject o, Vector3d v)
Check the intersection this and o against vector v.boolean
check2DIntersection(ConvexObject o)
Check the intersections of the projection on the xOy-plane of this and o The algorithm is the following: for each edge, determinate the normal vector and project all the points of this and o on the normal.boolean
check2DTrueIntersection(ConvexObject o)
Check the intersections of the projection on the xOy-plane of this and o The algorithm is the following: for each edge, determinate the normal vector and project all the points of this and o on the normal.protected void
drawAreas(java.awt.Graphics2D g2d)
int
isBehind(ConvexObject o)
Check if o is behind this.-
Methods inherited from class org.scilab.forge.scirenderer.implementation.g2d.motor.AbstractDrawable3DObject
draw, getColorsBarycenter, getNormal, getPrecedence, getProjectedContour, getProjectedPolyLine, getProvidedNormal, is2D, isBehind, isBehind, isDegenerate, isEqual, isGreaterOrEqual, isLowerOrEqual, isMonochromatic, isNanOrInf, isNanOrInf, isNegativeOrNull, isNull, isPlanar, isPositiveOrNull, minmax2D, minmax3D, resetDefaultPrecedence, setNormal, setPrecedence
-
-
-
-
Constructor Detail
-
ConvexObject
public ConvexObject(Vector3d[] vertices, java.awt.Color[] colors) throws InvalidPolygonException
Default constructor- Parameters:
vertices
- the verticescolors
- the colors- Throws:
InvalidPolygonException
-
-
Method Detail
-
breakObject
public abstract java.util.List<ConvexObject> breakObject(ConvexObject o)
Abstract method Break this ConvexObject against the ConvexObject o- Parameters:
o
- a ConvexObject- Returns:
- a list of ConvexObject.
-
breakObject
public abstract java.util.List<ConvexObject> breakObject(Vector4d v)
Abstract method Break this ConvexObject against a plane- Parameters:
v
- plane definition- Returns:
- a list of ConvexObject.
-
addArea
public void addArea(ConvexObject co)
-
drawAreas
protected void drawAreas(java.awt.Graphics2D g2d)
-
areCoplanar
public boolean areCoplanar(ConvexObject o)
Test the coplanarity of two objects- Parameters:
o
- a ConvexObject- Returns:
- true if the two objects are coplanar
-
isBehind
public int isBehind(ConvexObject o)
Check if o is behind this. Take care: the algorithms used are for convex objects (typically tri-tri, seg-seg or tri-seg)- Returns:
- true if o is behind this
-
check2DIntersection
public boolean check2DIntersection(ConvexObject o)
Check the intersections of the projection on the xOy-plane of this and o The algorithm is the following: for each edge, determinate the normal vector and project all the points of this and o on the normal. If the intersection of [this.min,this.max] and [o.min, o.max] is empty, then we have a separating line so the two objects are separated.- Parameters:
o
- the object to test with this- Returns:
- true if there is a collision
-
check2DTrueIntersection
public boolean check2DTrueIntersection(ConvexObject o)
Check the intersections of the projection on the xOy-plane of this and o The algorithm is the following: for each edge, determinate the normal vector and project all the points of this and o on the normal. If the intersection of [this.min,this.max] and [o.min, o.max] is empty, then we have a separating line so the two objects are separated.- Parameters:
o
- the object to test with this- Returns:
- true if there is a collision
-
check
protected int check(ConvexObject o, Vector3d v)
Check the intersection this and o against vector v. The algorithm is just to project this and o on the vector v and to check if the two projected sets can be separated.- Parameters:
v
- the vector where to project- Returns:
- 1 if o is behind this, 0 if it is undeterminated and -1 if this is behind o.
-
-