Class Face

java.lang.Object
eu.iv4xr.framework.spatial.meshes.Face
All Implemented Interfaces:
Iterable<Integer>

public class Face extends Object implements Iterable<Integer>
Represent a polygon, described by a set of vertices, stored in an array called vertices. Each vertex is represented by just an integer (think of it as the id of the vertex), so it does not describe the actual position of the vertex in the space (another information is needed to map the vertices to actual positions). Two vertices in the consecutive positions in the array "vertices" are assumed to be connected with a line. So, for all i, vertices[i] is connected to vertices[i+1], and the last one in the array, vertices[N-1] is connected to vertices[0]. In this way the array describes a polygon.
Author:
Naraenda
  • Field Details

    • vertices

      public int[] vertices
  • Constructor Details

    • Face

      public Face(int[] vertices)
  • Method Details

    • iterator

      public Iterator<Integer> iterator()
      Specified by:
      iterator in interface Iterable<Integer>
    • center

      public Vec3 center(List<Vec3> vertexMap)
      Given a list that maps vertex-indices to their real positions, this method calculate the center/middle point of this Face.
    • containsEdge

      public boolean containsEdge(Edge e)
      Check if the given edge is an edge of this Face.
    • area

      public float area(List<Vec3> vertexMap)
    • toString

      public String toString(ArrayList<Vec3> concreteVertices)
    • isConnected

      public static boolean isConnected(Face a, Face b)
      Check if two Faces are 'connected'. The method defines 'connected' to mean that the two Faces share at least one edge. This works well if the Facses are convex and have no overlapping edge (except if it is common).
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • distFromPoint

      public float distFromPoint(Vec3 w, ArrayList<Vec3> concreteVertices)
      Return an unsigned distance from a point w to this Face. The distance is defined as follows. Imagine first the 3D shape obtained by extruding this Face along its normal vector. Let's call this shape the extruding prism of this Face. If the the point w is strictly inside this prism, its distance is defines as its distance to the Face along the normal vector. Otherwise, the point is either strictly outside the prism, or at the prism's border. Then its distance to this Face is defined as its distance to the closest edge of the Face. Taken from: https://www.iquilezles.org/www/articles/triangledistance/triangledistance.htm
    • clamp

      static float clamp(float x)
      Clamping x between 0 and 1. That is, if x≤0, we return 0, if x≥1 we return 1, and else the original x is returned.
    • main

      public static void main(String[] args)