Assuming:
1. That given U anv V aren't collinear.
2. That O,U and V can be projected in the XY plane

@param mesh
@param triangles
@param o
@param u
@param v
544493
public static void updateTextureCoordinates( Mesh mesh, 
                                                 List<DelaunayTriangle> triangles,
                                                 double scale,
                                                 Point o,
                                                 Point u, 
                                                 Point v )
    {
        FloatBuffer tcBuf;
        float x,y,a,b;        
        final float ox = (float)scale*o.getXf();
        final float oy = (float)scale*o.getYf();
        final float ux = (float)scale*u.getXf();
        final float uy = (float)scale*u.getYf();
        final float vx = (float)scale*v.getXf();
        final float vy = (float)scale*v.getYf();
        final float vCu = (vx*uy-vy*ux);
        final boolean doX = Math.abs( ux ) > Math.abs( uy );
        
        tcBuf = prepareTextureCoordinateBuffer(mesh,0,2*3*triangles.size());
        tcBuf.rewind();

        for( DelaunayTriangle t : triangles )
        {
            for( int i=0; i<3; i++ )
            {
                x = t.points[i].getXf()-ox;
                y = t.points[i].getYf()-oy;

                // Calculate the texture coordinate in the UV plane
                a = (uy*x - ux*y)/vCu;                
                if( doX )
                {
                    b = (x - a*vx)/ux;
                }
                else
                {
                    b = (y - a*vy)/uy;                    
                }                
                tcBuf.put( a );
                tcBuf.put( b );
            }
        }
    }
1249566
public static double angle(NumberVector v1, NumberVector v2, NumberVector o) {
    final int dim1 = v1.getDimensionality(), dim2 = v2.getDimensionality(),
        dimo = o.getDimensionality();
    final int mindim = (dim1 <= dim2) ? dim1 : dim2;
    // Essentially, we want to compute this:
    // v1' = v1 - o, v2' = v2 - o
    // v1'.transposeTimes(v2') / (v1'.euclideanLength()*v2'.euclideanLength());
    // We can just compute all three in parallel.
    double cross = 0, l1 = 0, l2 = 0;
    for(int k = 0; k < mindim; k++) {
      final double ok = k < dimo ? o.doubleValue(k) : 0.;
      final double r1 = v1.doubleValue(k) - ok;
      final double r2 = v2.doubleValue(k) - ok;
      cross += r1 * r2;
      l1 += r1 * r1;
      l2 += r2 * r2;
    }
    for(int k = mindim; k < dim1; k++) {
      final double ok = k < dimo ? o.doubleValue(k) : 0.;
      final double r1 = v1.doubleValue(k) - ok;
      l1 += r1 * r1;
    }
    for(int k = mindim; k < dim2; k++) {
      final double ok = k < dimo ? o.doubleValue(k) : 0.;
      final double r2 = v2.doubleValue(k) - ok;
      l2 += r2 * r2;
    }
    final double a = (cross == 0.) ? 0. : //
        (l1 == 0. || l2 == 0.) ? 1. : //
            FastMath.sqrt((cross / l1) * (cross / l2));
    return (a < 1.) ? a : 1.;
  }
675907
function (face, v) {
                getTriangles(face, v);
                for (var k = 0; k < triangles.length; k++) {
                    //triangle[k] = "1//1"
                    //Split the data for getting position and normals
                    var point = triangles[k].split("//"); // ["1", "1"]
                    // We check indices, and normals
                    var indicePositionFromObj = parseInt(point[0]) - 1;
                    var indiceNormalFromObj = parseInt(point[1]) - 1;
                    setData(indicePositionFromObj, 1, //Default value for uv
                    indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
                    BABYLON.Vector2.Zero(), normals[indiceNormalFromObj]);
                }
                //Reset variable for the next line
                triangles = [];
            }
665008
public static void projectionCombine( DMatrixRMaj M , Vector3D_F64 T , DMatrixRMaj P ) {
		CommonOps_DDRM.insert(M,P,0,0);
		P.data[3] = T.x;
		P.data[7] = T.y;
		P.data[11] = T.z;
	}
1049996
@Pure
	private static boolean containsTrianglePoint(
			int i0, int i1, double[] v, double[] u1, double[] u2, double[] u3) {
		// is T1 completly inside T2?
		// check if V0 is inside tri(U0,U1,U2)
		double a  = u2[i1] - u1[i1];
		double b  = -(u2[i0] - u1[i0]);
		double c  = -a * u1[i0] - b * u1[i1];
		double d0 = a * v[i0] + b * v[i1] + c;

		a         = u3[i1] - u2[i1];
		b         = -(u3[i0] - u2[i0]);
		c         = -a * u2[i0] - b * u2[i1];
		double d1 = a * v[i0] + b * v[i1] + c;

		a         = u1[i1] - u2[i1];
		b         = -(u1[i0] - u3[i0]);
		c         = -a * u3[i0] - b * u3[i1];
		double d2 = a * v[i0] + b * v[i1] + c;

		return ((d0*d1>0.)&&(d0*d2>0.0));
	}
927465
private static Triangle findnext1(Vector3 p, Triangle v) {
		if (!v.abnext.halfplane && PointLineTest.pointLineTest(v.a, v.b, p) == PointLinePosition.RIGHT)
			return v.abnext;
		if (!v.bcnext.halfplane && PointLineTest.pointLineTest(v.b, v.c, p) == PointLinePosition.RIGHT)
			return v.bcnext;
		if (!v.canext.halfplane && PointLineTest.pointLineTest(v.c, v.a, p) == PointLinePosition.RIGHT)
			return v.canext;
		if (PointLineTest.pointLineTest(v.a, v.b, p) == PointLinePosition.RIGHT)
			return v.abnext;
		if (PointLineTest.pointLineTest(v.b, v.c, p) == PointLinePosition.RIGHT)
			return v.bcnext;
		if (PointLineTest.pointLineTest(v.c, v.a, p) == PointLinePosition.RIGHT)
			return v.canext;
		return null;
	}
1272470
function(gl, vertices, uv) {
  var verticesBuf = createBuffer(gl, new Float32Array(vertices))
  var uvBuf = createBuffer(gl, new Float32Array(uv))

  var mesh = createVAO(gl, [
      { buffer: verticesBuf,
        size: 3
      },
      {
        buffer: uvBuf,
        size: 2
      }
      ])
  mesh.length = vertices.length/3

  return mesh
}
113101
private static double getPlaneAngle(float[] v1, float[] v2, float[] v3, float[] u1, float[] u2, float[] u3) {
		float[] cross1 = Vector.crossProduct(new float[] { v2[0] - v1[0], v2[1] - v1[1], v2[2] - v1[2] }, new float[] { v3[0] - v1[0], v3[1] - v1[1], v3[2] - v1[2] });
		float[] cross2 = Vector.crossProduct(new float[] { u2[0] - u1[0], u2[1] - u1[1], u2[2] - u1[2] }, new float[] { u3[0] - u1[0], u3[1] - u1[1], u3[2] - u1[2] });

		float num = Vector.dot(cross1, cross2);
		float den = Vector.length(cross1) * Vector.length(cross2);

		float a = num / den;
		if (a > 1) {
			a = 1;
		}
		if (a < -1) {
			a = -1;
		}
		double result = Math.acos(a);

		return result;
	}
24928
public void set(Vector3D v1, Vector3D v2) {
        this.MODE = LINES;
        this.x1 = v1.getX();
        this.y1 = v1.getY();
        this.z1 = v1.getZ();
        this.x2 = v2.getX();
        this.y2 = v2.getY();
        this.z2 = v2.getZ();
        calcG();
        dx[0] = x1 - this.x;
        dx[1] = x2 - this.x;
        dy[0] = y1 - this.y;
        dy[1] = y2 - this.y;
        dz[0] = z1 - this.z;
        dz[1] = z2 - this.z;
        if (dashed) calcDashedLine();
    }
1006723
private boolean computeUWV() {
        bidiag.getDiagonal(diag,off);
        qralg.setMatrix(numRowsT,numColsT,diag,off);

//        long pointA = System.currentTimeMillis();
        // compute U and V matrices
        if( computeU )
            Ut = bidiag.getU(Ut,true,compact);
        if( computeV )
            Vt = bidiag.getV(Vt,true,compact);

        qralg.setFastValues(false);
        if( computeU )
            qralg.setUt(Ut);
        else
            qralg.setUt(null);
        if( computeV )
            qralg.setVt(Vt);
        else
            qralg.setVt(null);

//        long pointB = System.currentTimeMillis();

        boolean ret = !qralg.process();

//        long pointC = System.currentTimeMillis();
//        System.out.println("  compute UV "+(pointB-pointA)+"  QR = "+(pointC-pointB));

        return ret;
    }
1110908
function (face, v) {
                //Get the indices of triangles for each polygon
                getTriangles(face, v);
                for (var k = 0; k < triangles.length; k++) {
                    //triangle[k] = "1/1/1"
                    //Split the data for getting position, uv, and normals
                    var point = triangles[k].split("/"); // ["1", "1", "1"]
                    // Set position indice
                    var indicePositionFromObj = parseInt(point[0]) - 1;
                    // Set uv indice
                    var indiceUvsFromObj = parseInt(point[1]) - 1;
                    // Set normal indice
                    var indiceNormalFromObj = parseInt(point[2]) - 1;
                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
                    );
                }
                //Reset variable for the next line
                triangles = [];
            }
1312550
def ray_triangle_intersection(v1, v2, v3, o, d):
    '''
    '''
    eps = 1e-6
    e1 = sub(v2, v1)
    e2 = sub(v3, v1)
    p = cross(d, e2)
    det = dot(e1, p)
    if abs(det) < eps:
        return None
    inv = 1.0 / det
    t = sub(o, v1)
    u = dot(t, p) * inv
    if u < 0 or u > 1:
        return None
    q = cross(t, e1)
    v = dot(d, q) * inv
    if v < 0 or v > 1:
        return None
    t = dot(e2, q) * inv
    if t > eps:
        return t
    return None
952351
def triangle_intersects_plane(mesh, tid, plane):
    
    dists = [point_to_plane_dist(mesh.verts[vid], plane)
             for vid in mesh.tris[tid]]
    side = np.sign(dists)
    return not (side[0] == side[1] == side[2])
659027
private static Triangle findnext2(Vector3 p, Triangle v) {
		if (v.abnext != null && !v.abnext.halfplane)
			return v.abnext;
		if (v.bcnext != null && !v.bcnext.halfplane)
			return v.bcnext;
		if (v.canext != null && !v.canext.halfplane)
			return v.canext;
		return null;
	}
56421
def all_coplanar(triangles):
    
    triangles = np.asanyarray(triangles, dtype=np.float64)
    if not util.is_shape(triangles, (-1, 3, 3)):
        raise ValueError('Triangles must be (n,3,3)!')

    test_normal = normals(triangles)[0]
    test_vertex = triangles[0][0]
    distances = point_plane_distance(points=triangles[1:].reshape((-1, 3)),
                                     plane_normal=test_normal,
                                     plane_origin=test_vertex)
    all_coplanar = np.all(np.abs(distances) < tol.zero)
    return all_coplanar
880562
public void prepareTriangulation( TriangulationContext<?> tcx )
    {
        int hint = _points.size();
        if(_steinerPoints != null) {
            hint += _steinerPoints.size();
        }
        if( _holes != null ) {
            for (Polygon p : _holes) {
                hint += p.pointCount();
            }
        }
        HashMap<TriangulationPoint, TriangulationPoint> uniquePts = new HashMap<TriangulationPoint, TriangulationPoint>(hint);
        TriangulationPoint.mergeInstances(uniquePts, _points);
        if(_steinerPoints != null) {
            TriangulationPoint.mergeInstances(uniquePts, _steinerPoints);
        }
        if( _holes != null ) {
            for (Polygon p : _holes) {
                TriangulationPoint.mergeInstances(uniquePts, p._points);
            }
        }
        if( m_triangles == null )
        {
            m_triangles = new ArrayList<DelaunayTriangle>( _points.size() );
        }
        else
        {
            m_triangles.clear();
        }

        // Outer constraints
        for( int i = 0; i < _points.size()-1 ; i++ )
        {
            tcx.newConstraint( _points.get( i ), _points.get( i+1 ) );
        }
        tcx.newConstraint( _points.get( 0 ), _points.get( _points.size()-1 ) );

        // Hole constraints
        if( _holes != null )
        {
            for( Polygon p : _holes )
            {
                for( int i = 0; i < p._points.size()-1 ; i++ )
                {
                    tcx.newConstraint( p._points.get( i ), p._points.get( i+1 ) );
                }
                tcx.newConstraint( p._points.get( 0 ), p._points.get( p._points.size()-1 ) );            
            }
        }
        tcx.addPoints(uniquePts.keySet());
    }
941952
public void sub(Vector3d v1) {
        x -= v1.x;
        y -= v1.y;
        z -= v1.z;
    }