p2 can be a vector
546525
def triangle_area(p0, p1, p2):
    if p2.ndim < 2:
        p2 = p2[np.newaxis, :]
    ''''''
    area = 0.5 * np.abs(p0[0] * p1[1] - p0[0] * p2[:,1] +
           p1[0] * p2[:,1] - p1[0] * p0[1] +
           p2[:,0] * p0[1] - p2[:,0] * p1[1])
    return area
126521
public Vector2d fma(Vector2dc a, Vector2dc b) {
        return fma(a, b, thisOrNew());
    }
346667
public static final double getAngleBetweenTwoLines(final Point2D p0, final Point2D p1, final Point2D p2)
    {
        return getAngleFromSSS(p0.distance(p1), p1.distance(p2), p0.distance(p2));
    }
310120
def add_vectors(vec_a, vec_b, periodic):
    '''

    '''
    moved = noperiodic(np.array([vec_a, vec_b]), periodic)
    return vec_a + vec_b
1374171
def line(p1, p2):
    
    A = (p1[1] - p2[1])
    B = (p2[0] - p1[0])
    C = (p1[0]*p2[1] - p2[0]*p1[1])
    return A, B, -C
681113
public boolean process( DMatrixRMaj P ) {
		if( !svd.decompose(P) )
			return false;

		svd.getU(Ut,true);
		svd.getV(V,false);
		double sv[] = svd.getSingularValues();

		SingularOps_DDRM.descendingOrder(Ut,true,sv,3,V,false);

		// compute W+, which is transposed and non-negative inverted
		for (int i = 0; i < 3; i++) {
			Wt.unsafe_set(i,i, 1.0/sv[i]);
		}

		// get the pseudo inverse
		// A+ = V*(W+)*U'
		CommonOps_DDRM.mult(V,Wt,tmp);
		CommonOps_DDRM.mult(tmp, Ut,PA);

		// Vector U, which is P*U = 0
		SpecializedOps_DDRM.subvector(V,0,3,V.numRows,false,0,ns);

		return true;
	}
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;
	}
813187
function(point) {
                var P = point.elements || point;
                var A = this.anchor.elements, N = this.normal.elements;
                var dot = (A[0] - P[0]) * N[0] + (A[1] - P[1]) * N[1] + (A[2] - (P[2] || 0)) * N[2];
                return vector.create([P[0] + N[0] * dot, P[1] + N[1] * dot, (P[2] || 0) + N[2] * dot]);
              }
752401
def reflect(vec1, vec2):
    """"""
    if isinstance(vec1, Vector3) and isinstance(vec2, Vector3) \
            or isinstance(vec1, Vector4) and isinstance(vec2, Vector4):
        return 2 * dot(vec1, vec2) * vec2 - vec2
    else:
        raise ValueError("vec1 and vec2 must both be a Vector type")
1139041
def m_seg(p1, p2, rad, dist):
    
    v = vector(p1, p2)
    m = unit(rotate(v, rad), dist)
    return translate(p1, m), translate(p2, m)
1009144
static double inner_product(SparseVector vec1, SparseVector vec2)
    {
        Iterator<Map.Entry<Integer, Double>> it;
        SparseVector other;
        if (vec1.size() < vec2.size())
        {
            it = vec1.entrySet().iterator();
            other = vec2;
        }
        else
        {
            it = vec2.entrySet().iterator();
            other = vec1;
        }
        double prod = 0;
        while (it.hasNext())
        {
            Map.Entry<Integer, Double> entry = it.next();
            prod += entry.getValue() * other.get(entry.getKey());
        }
        return prod;
    }
1261305
def vectors2angle(v1, v2):
    
    cosang = np.dot(v1, v2)
    sinang = np.linalg.norm(np.cross(v1, v2))
    return np.arctan2(sinang, cosang)
517392
public Vector2f lerp(Vector2fc other, float t, Vector2f dest) {
        dest.x = x + (other.x() - x) * t;
        dest.y = y + (other.y() - y) * t;
        return dest;
    }
936564
function scale(a, s){
    return Vector2(a.x * s, a.y * s);
  }
680894
def dot(vec1, vec2):
        """"""
        if isinstance(vec1, Vector2) \
                and isinstance(vec2, Vector2):
            return ((vec1.X * vec2.X) + (vec1.Y * vec2.Y))
        else:
            raise TypeError("vec1 and vec2 must be Vector2's")
364405
def vectorAngle(vec1,vec2):
    '''
    
    '''
    if vec1.ndim == 1:
        assert vec2.ndim == 3
        vec1 = vectorToField(vec1, vec2.shape[:2])

    if vec2.ndim == 1:
        assert vec1.ndim == 3
        vec2 = vectorToField(vec2, vec1.shape[1:])
    a = np.arccos(
                np.einsum('ijk,ijk->jk', vec1,vec2)
                /( norm(vec1,axis=0) * norm(vec2,axis=0) ) )
    #take smaller of both possible angles:
    ab = np.abs(np.pi-a)
    with np.errstate(invalid='ignore'):
        i = a>ab
    a[i] = ab[i]
    return a
951862
def cross_v2(vec1, vec2):
    

    return vec1.y * vec2.x - vec1.x * vec2.y