org.scilab.forge.scirenderer.implementation.g2d.motor
Class Triangle

java.lang.Object
  extended by org.scilab.forge.scirenderer.implementation.g2d.motor.AbstractDrawable3DObject
      extended by org.scilab.forge.scirenderer.implementation.g2d.motor.ConvexObject
          extended by org.scilab.forge.scirenderer.implementation.g2d.motor.Triangle

public class Triangle
extends ConvexObject

Author:
Calixte DENIZET

Field Summary
protected  java.util.List<Segment> segments
           
 
Fields inherited from class org.scilab.forge.scirenderer.implementation.g2d.motor.AbstractDrawable3DObject
bbox, colors, degenerated, is2d, marked, marked2, normal, nv0v1, precedence, PRECISION, v0, v0v1, v1, vertices, zindex
 
Constructor Summary
Triangle(Vector3d[] vertices, java.awt.Color[] colors)
           
Triangle(Vector3d[] vertices, java.awt.Color[] colors, Vector3d normal)
           
Triangle(Vector3d[] vertices, Vector3d[] textureCoords, java.awt.image.BufferedImage image, Texture.Filter filter)
           
 
Method Summary
 boolean addSegment(Segment s)
           
protected static java.util.List<ConvexObject> breakIntersectingTriangles(Triangle t1, Triangle t2)
          Get the broken triangles in following the intersection of the planes containing t1 and t2.
 java.util.List<ConvexObject> breakObject(ConvexObject o)
          Abstract method Break this ConvexObject against the ConvexObject o
 java.util.List<ConvexObject> breakObject(Segment o)
           
 java.util.List<ConvexObject> breakObject(Triangle o)
           
 java.util.List<ConvexObject> breakObject(Vector4d v)
          Abstract method Break this ConvexObject against a plane
protected static java.util.List<ConvexObject> breakSegmentOnTriangle(Triangle t, Segment s)
           
protected static java.util.List<ConvexObject> breakTriangleOnLine(Triangle t, Vector3d p, Vector3d n)
          Break a triangle according to its intersection with a line containing p in the plane of the triangle and orthogonal to n The triangle and the line are supposed to be coplanar.
 void draw(java.awt.Graphics2D g2d)
          Draw this object on a Graphics2D object
protected  double getSegmentIntersection(Segment s)
           
protected  SpritedRectangle getSprite()
           
 int isBehind(ConvexObject o)
          Check if o is behind this.
protected  boolean isCoplanar(Segment s)
           
protected  boolean isCoplanar(Triangle t)
           
 boolean isIn2D()
           
protected  boolean isPointInside(Vector3d v)
           
protected  boolean isPointInside(Vector3d v, boolean checkCoplanarity)
           
protected  boolean isSegmentAcross(Segment s)
           
protected  boolean isSegmentInside(Segment s)
           
protected  boolean isSegmentIntersects(Segment s)
           
 boolean pointOnVertices(Vector3d p)
           
 void removeSegment(Segment s)
           
 void replaceSegment(Segment s, java.util.List<Segment> segs)
           
protected  void setSprite(SpritedRectangle sprite)
           
 java.lang.String toString()
           
 
Methods inherited from class org.scilab.forge.scirenderer.implementation.g2d.motor.ConvexObject
addArea, areCoplanar, check, check2DIntersection, check2DTrueIntersection, drawAreas
 
Methods inherited from class org.scilab.forge.scirenderer.implementation.g2d.motor.AbstractDrawable3DObject
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

segments

protected java.util.List<Segment> segments
Constructor Detail

Triangle

public Triangle(Vector3d[] vertices,
                java.awt.Color[] colors,
                Vector3d normal)
         throws InvalidPolygonException
Throws:
InvalidPolygonException

Triangle

public Triangle(Vector3d[] vertices,
                java.awt.Color[] colors)
         throws InvalidPolygonException
Throws:
InvalidPolygonException

Triangle

public Triangle(Vector3d[] vertices,
                Vector3d[] textureCoords,
                java.awt.image.BufferedImage image,
                Texture.Filter filter)
         throws InvalidPolygonException
Throws:
InvalidPolygonException
Method Detail

isBehind

public int isBehind(ConvexObject o)
Description copied from class: ConvexObject
Check if o is behind this. Take care: the algorithms used are for convex objects (typically tri-tri, seg-seg or tri-seg)

Overrides:
isBehind in class ConvexObject
Returns:
true if o is behind this

isIn2D

public boolean isIn2D()

addSegment

public boolean addSegment(Segment s)

pointOnVertices

public boolean pointOnVertices(Vector3d p)

removeSegment

public void removeSegment(Segment s)

replaceSegment

public void replaceSegment(Segment s,
                           java.util.List<Segment> segs)

breakObject

public java.util.List<ConvexObject> breakObject(ConvexObject o)
Description copied from class: ConvexObject
Abstract method Break this ConvexObject against the ConvexObject o

Specified by:
breakObject in class ConvexObject
Parameters:
o - a ConvexObject
Returns:
a list of ConvexObject.

breakObject

public java.util.List<ConvexObject> breakObject(Triangle o)

breakObject

public java.util.List<ConvexObject> breakObject(Segment o)

setSprite

protected void setSprite(SpritedRectangle sprite)

getSprite

protected SpritedRectangle getSprite()

draw

public void draw(java.awt.Graphics2D g2d)
Description copied from class: AbstractDrawable3DObject
Draw this object on a Graphics2D object

Specified by:
draw in class AbstractDrawable3DObject
Parameters:
g2d - the Graphics2d object where to draw

breakObject

public java.util.List<ConvexObject> breakObject(Vector4d v)
Description copied from class: ConvexObject
Abstract method Break this ConvexObject against a plane

Specified by:
breakObject in class ConvexObject
Parameters:
v - plane definition
Returns:
a list of ConvexObject.

isPointInside

protected boolean isPointInside(Vector3d v)

isPointInside

protected boolean isPointInside(Vector3d v,
                                boolean checkCoplanarity)

isCoplanar

protected boolean isCoplanar(Segment s)

isCoplanar

protected boolean isCoplanar(Triangle t)

isSegmentAcross

protected boolean isSegmentAcross(Segment s)

isSegmentInside

protected boolean isSegmentInside(Segment s)

isSegmentIntersects

protected boolean isSegmentIntersects(Segment s)

getSegmentIntersection

protected double getSegmentIntersection(Segment s)

breakSegmentOnTriangle

protected static java.util.List<ConvexObject> breakSegmentOnTriangle(Triangle t,
                                                                     Segment s)

breakTriangleOnLine

protected static java.util.List<ConvexObject> breakTriangleOnLine(Triangle t,
                                                                  Vector3d p,
                                                                  Vector3d n)
Break a triangle according to its intersection with a line containing p in the plane of the triangle and orthogonal to n The triangle and the line are supposed to be coplanar.

Parameters:
t - the triangle to break
p - a point of the line
n - a vector
Returns:
a list of triangles

breakIntersectingTriangles

protected static java.util.List<ConvexObject> breakIntersectingTriangles(Triangle t1,
                                                                         Triangle t2)
Get the broken triangles in following the intersection of the planes containing t1 and t2. The planes containing t1 and t2 are supposed to be secant.

Parameters:
t1 - the first triangle
t2 - the second triangle
Returns:
an array of length 2 containing the resulting triangles for t1 and t2.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object