Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.rico.engine.geometry
Class Triangle

    java.lang.Object
      de.rico.engine.geometry.Triangle

    public class Triangle

extends java.lang.Object

This class represents a triangle (polygon) that can be part of a mesh.

Author:
  Frank Bruns

Constructor Summary
`Triangle(Point3D p1, Point3D p2, Point3D p3)` Creates a triangle with the specified points as vertices.
`Triangle(Point3D p1, Point3D p2, Point3D p3, boolean calcNormal)` Creates a triangle with the specified points as vertices.

Method Summary
`void` | `calculateNormals()` Calculates the normal for the triangle
`Triangle` | `clone()`
`float` | `getLengthV1V2()` Returns the length of the edge between vertex1 and vertex2
`float` | `getLengthV1V3()` Returns the length of the edge between vertex1 and vertex3
`float` | `getLengthV2V3()` Returns the length of the edge between vertex2 and vertex3
`Point3D` | `getVertex1()` Gets the first vertex of the triangle.
`Point3D` | `getVertex2()` Gets the second vertex of the triangle.
`Point3D` | `getVertex3()` Gets the third vertex of the triangle.
`Point3D[]` | `getVertices()` Returns an array with the three vertices of the triangle
`boolean` | `hasVertex(Point3D vert)` Checks whether the specified vertex is a vertex of the triangle
`void` | `setVertex1(Point3D point)` Sets the first vertex if the triangle
`void` | `setVertex2(Point3D point)` Sets the second vertex if the triangle
`void` | `setVertex3(Point3D point)` Sets the third vertex if the triangle
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Triangle

    public Triangle(Point3D p1,
                    Point3D p2,
                    Point3D p3)

  Creates a triangle with the specified points as vertices. The triangle can be used as a face of a mesh. The normals of the triangle's vertices is calculated automatically.
  Note: Please specify point counter-clockwise

  Parameters:
    `p1` - point that will be vertex1
    `p2` - point that will be vertex2
    `p3` - point that will be vertex3

### Triangle

    public Triangle(Point3D p1,
                    Point3D p2,
                    Point3D p3,
                    boolean calcNormal)

  Creates a triangle with the specified points as vertices. The triangle can be used as a face of a mesh. You can specify whether the normals should be calculated or not. If you don't calculate the normal's the vertices will have a `null` object as a normal
  Note: Please specify point counter-clockwise

  Parameters:
    `p1` - point that will be vertex1
    `p2` - point that will be vertex2
    `p3` - point that will be vertex3
    `calcNormal` - calculate normals? --> true=yes, false=no

Method Detail

### calculateNormals

    public void calculateNormals()

  Calculates the normal for the triangle

### getLengthV1V2

    public float getLengthV1V2()

  Returns the length of the edge between vertex1 and vertex2

  Returns:
    length of edge between vertex1 and vertex2

### getLengthV1V3

    public float getLengthV1V3()

  Returns the length of the edge between vertex1 and vertex3

  Returns:
    length of edge between vertex1 and vertex3

### getLengthV2V3

    public float getLengthV2V3()

  Returns the length of the edge between vertex2 and vertex3

  Returns:
    length of edge between vertex2 and vertex3

### getVertices

    public Point3D[] getVertices()

  Returns an array with the three vertices of the triangle

  Returns:
    array containing the triangles vertices (three fields)

### getVertex1

    public Point3D getVertex1()

  Gets the first vertex of the triangle.
  Note: The coordinates of this vertex are not in world coordinates. If you would like to have world coordinates you will have to add the position of the mesh this triangle belongs to to the vertex.

  Returns:
    first vertex

### setVertex1

    public void setVertex1(Point3D point)

  Sets the first vertex if the triangle

  Parameters:
    `point` - point that will be the first vertex

### getVertex2

    public Point3D getVertex2()

  Gets the second vertex of the triangle.
  Note: The coordinates of this vertex are not in world coordinates. If you would like to have world coordinates you will have to add the position of the mesh this triangle belongs to to the vertex.

  Returns:
    second vertex

### setVertex2

    public void setVertex2(Point3D point)

  Sets the second vertex if the triangle

  Parameters:
    `point` - point that will be the second vertex

### getVertex3

    public Point3D getVertex3()

  Gets the third vertex of the triangle.
  Note: The coordinates of this vertex are not in world coordinates. If you would like to have world coordinates you will have to add the position of the mesh this triangle belongs to to the vertex.

  Returns:
    third vertex

### setVertex3

    public void setVertex3(Point3D point)

  Sets the third vertex if the triangle

  Parameters:
    `point` - that will be the third vertex

### hasVertex

    public boolean hasVertex(Point3D vert)

  Checks whether the specified vertex is a vertex of the triangle

  Parameters:
    `vert` - vertex to check with triangle
  Returns:
    is vertex point of triangle? --> true=yes, false=no

### clone

    public Triangle clone()

  Overrides:
    `clone` in class `java.lang.Object`

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD