Class MeshUtil


  • public class MeshUtil
    extends Object
    • Constructor Summary

      Constructors 
      Constructor Description
      MeshUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void cross​(double x1, double y1, double z1, double x2, double y2, double z2, double[] out)
      Cross product between vectors V1 and V2.
      static double dotProduct​(double x1, double y1, double z1, double x2, double y2, double z2)
      Dot product between vectors V1 and V2.
      static long edgeID​(int v1, int v2)
      Builds a unique id for an edge between the two specified vertices.
      static String edgeStr​(long l)  
      static int edgeV1​(long l)
      Returns the id of the first vertex of the specified edge.
      static int edgeV2​(long l)
      Returns the id of the second vertex of the specified edge.
      static double maxZ​(Vertices vertices, long v0, long v1, long v2, double eps)
      Return the maximal Z value of a given triangle, rounded to twice the specified scale.
      static double minZ​(Vertices vertices, long v0, long v1, long v2, double eps)
      Return the minimal Z value of a given triangle, rounded to twice the specified scale.
      static double mround​(double v, double eps, int mod, int rem)
      Rounds a position to a multiple of small number, plus reminder.
      static String triangleStr​(Mesh mesh, long id)
      Produces a string representation of a triangle.
    • Constructor Detail

      • MeshUtil

        public MeshUtil()
    • Method Detail

      • dotProduct

        public static final double dotProduct​(double x1,
                                              double y1,
                                              double z1,
                                              double x2,
                                              double y2,
                                              double z2)
        Dot product between vectors V1 and V2.
        Parameters:
        x1 -
        y1 -
        z1 -
        x2 -
        y2 -
        z2 -
        Returns:
      • cross

        public static final void cross​(double x1,
                                       double y1,
                                       double z1,
                                       double x2,
                                       double y2,
                                       double z2,
                                       double[] out)
        Cross product between vectors V1 and V2. Stores the results in the specified double array.
        Parameters:
        x1 -
        y1 -
        z1 -
        x2 -
        y2 -
        z2 -
        out - a double array of size at least 3 to store the coordinates of resulting vector.
      • edgeID

        public static final long edgeID​(int v1,
                                        int v2)
        Builds a unique id for an edge between the two specified vertices. Such an edge is undirected; the edge v1->v2 and v2->v1 have the the same id.
        Parameters:
        v1 - the id of the first vertex.
        v2 - the id of the second vertex.
        Returns:
        the edge id, as a long.
      • edgeV1

        public static final int edgeV1​(long l)
        Returns the id of the first vertex of the specified edge.
        Parameters:
        l - the edge id.
        Returns:
        the first vertex id, as an int.
      • edgeV2

        public static final int edgeV2​(long l)
        Returns the id of the second vertex of the specified edge.
        Parameters:
        l - the edge id.
        Returns:
        the second vertex id, as an int.
      • edgeStr

        public static final String edgeStr​(long l)
      • mround

        public static final double mround​(double v,
                                          double eps,
                                          int mod,
                                          int rem)
        Rounds a position to a multiple of small number, plus reminder. This is used typically to ensure a ray will not cross a vertex in a mesh, causing a singularity.
        Parameters:
        v - the value to round.
        eps - the scale to round to.
        mod - the number of time eps to round. For instance if you put 2, everything will be a multiple of 2*eps.
        rem - the remainder to add to the rounded value. For instance if you put a remainder of 1 and a mod of, all values will be rounded to 2 times eps + eps.
        Returns:
        the rounded value.
      • minZ

        public static final double minZ​(Vertices vertices,
                                        long v0,
                                        long v1,
                                        long v2,
                                        double eps)
        Return the minimal Z value of a given triangle, rounded to twice the specified scale.
        Parameters:
        vertices - the vertices structure.
        v0 - the triangle first vertex.
        v1 - the triangle second vertex.
        v2 - the triangle third vertex. Order does not matter.
        eps - the rounding scale.
        Returns:
        the minimal Z value of the triangle, rounded to twice the specified scale.
      • maxZ

        public static final double maxZ​(Vertices vertices,
                                        long v0,
                                        long v1,
                                        long v2,
                                        double eps)
        Return the maximal Z value of a given triangle, rounded to twice the specified scale.
        Parameters:
        vertices - the vertices structure.
        v0 - the triangle first vertex.
        v1 - the triangle second vertex.
        v2 - the triangle third vertex. Order does not matter.
        eps - the rounding scale.
        Returns:
        the maximal Z value of the triangle, rounded to twice the specified scale.
      • triangleStr

        public static String triangleStr​(Mesh mesh,
                                         long id)
        Produces a string representation of a triangle.
        Parameters:
        mesh - the mesh.
        id - the if of the triangle in the mesh.
        Returns:
        a string representation.