叉乘
    vector 1: x1, y1, x2, y2
    vector 2: x1, y1, x3, y3
970610
def cross_product (x1, y1, x2, y2, x3, y3):
    
    return (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)
1336544
def cross(v, w):
    
    x = v[1] * w[2] - v[2] * w[1]
    y = v[2] * w[0] - v[0] * w[2]
    z = v[0] * w[1] - v[1] * w[0]
    return [x, y, z]
954431
public Vector3f mul(Vector3fc v, Vector3f dest) {
        dest.x = x * v.x();
        dest.y = y * v.y();
        dest.z = z * v.z();
        return dest;
    }
356435
def vector(p1, p2):
    '''
    '''
    return np.subtract(p1[COLS.XYZ], p2[COLS.XYZ])
327430
public static function dot(Vector $vector1, Vector $vector2) : float {
        $count = count($vector1);
        $value = 0;
        for ($i=0;$i<$count;$i++) {
            $value += ($vector1[$i] * $vector2[$i]);
        }
        return $value;
    }
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
85627
def cross(vec1, vec2):
        """"""
        if isinstance(vec1, Vector3) and isinstance(vec2, Vector3):
            vec3 = Vector3()
            vec3.x = (vec1.y * vec2.z) - (vec1.z * vec2.y)
            vec3.y = (vec1.z * vec2.x) - (vec1.x * vec2.z)
            vec3.z = (vec1.x * vec2.y) - (vec1.y * vec2.x)
            return vec3
        else:
            raise TypeError("vec1 and vec2 must be Vector3's")
1022518
def copyVector(self, vector1, vec2, start):
        
        vector2 = self.replacePatterns(vec2)
        length = min(len(vector1), len(vector2))
        if self.verbosity > 4:
            print("Copying Vector: ", vector2[start:start+length])
        p = 0
        for i in range(start, start + length):
            vector1[p] = vector2[i]
            p += 1
241378
def dot_product(p1, p2, o=(0, 0)):
    
    v1 = vector(o, p1)
    v2 = vector(o, p2)
    return v1[0] * v2[0] + v1[1] * v2[1]
1127369
def vector_projection(v1, v2):
    '''
    '''
    return scalar_projection(v1, v2) * v2 / np.linalg.norm(v2)
724921
def dot_v2(vec1, vec2):
    """"""

    return vec1.x * vec2.x + vec1.y * vec2.y
660530
public Vector2f fma(Vector2fc a, Vector2fc b, Vector2f dest) {
        dest.x = x + a.x() * b.x();
        dest.y = y + a.y() * b.y();
        return dest;
    }
913381
function mul(a, b){
    return Vector3(a.x*b.x, a.y*b.y, a.z*b.z);
  }
1155626
function bezier(x1, y1, x2, y2)
{
    var p1 = [x1, y1], p2 = [x2, y2],
        A = [null, null], B = [null, null], C = [null, null],

        bezCoOrd = function(time, ax)
        {
            C[ax] = 3 * p1[ax]; B[ax] = 3 * (p2[ax] - p1[ax]) - C[ax]; A[ax] = 1 - C[ax] - B[ax];
            return time * (C[ax] + time * (B[ax] + time * A[ax]));
        },

        xDeriv = function(time)
        {
            return C[0] + time * (2 * B[0] + 3 * A[0] * time);
        },

        xForT = function(time)
        {
            var x = time, i = 0, z;
            while (++i < 14)
            {
                z = bezCoOrd(x, 0) - time;
                if (Math.abs(z) < 1e-3) break;
                x -= z / xDeriv(x);
            }
            return x;
        };

    return function(time) {
        return bezCoOrd(xForT(time), 1);
    };
}
378482
public Vector3d hermite(Vector3dc t0, Vector3dc v1, Vector3dc t1, double t, Vector3d dest) {
        double t2 = t * t;
        double t3 = t2 * t;
        dest.x = (x + x - v1.x() - v1.x() + t1.x() + t0.x()) * t3 + (3.0 * v1.x() - 3.0 * x - t0.x() - t0.x() - t1.x()) * t2 + x * t + x;
        dest.y = (y + y - v1.y() - v1.y() + t1.y() + t0.y()) * t3 + (3.0 * v1.y() - 3.0 * y - t0.y() - t0.y() - t1.y()) * t2 + y * t + y;
        dest.z = (z + z - v1.z() - v1.z() + t1.z() + t0.z()) * t3 + (3.0 * v1.z() - 3.0 * z - t0.z() - t0.z() - t1.z()) * t2 + z * t + z;
        return dest;
    }
825320
def cross_product(p1, p2, o=(0, 0)):
    
    v1 = vector(o, p1)
    v2 = vector(o, p2)
    return v1[0] * v2[1] - v1[1] * v2[0]
1295840
function(v) {

      // [0, v'] = Q * [0, v] * Q'

      // Q
      var w1 = this['w'];
      var x1 = this['x'];
      var y1 = this['y'];
      var z1 = this['z'];

      // [0, v]
      var w2 = 0;
      var x2 = v[0];
      var y2 = v[1];
      var z2 = v[2];

      // Q * [0, v]
      var w3 = /*w1 * w2*/ -x1 * x2 - y1 * y2 - z1 * z2;
      var x3 = w1 * x2 + /*x1 * w2 +*/ y1 * z2 - z1 * y2;
      var y3 = w1 * y2 + /*y1 * w2 +*/ z1 * x2 - x1 * z2;
      var z3 = w1 * z2 + /*z1 * w2 +*/ x1 * y2 - y1 * x2;

      var w4 = w3 * w1 + x3 * x1 + y3 * y1 + z3 * z1;
      var x4 = x3 * w1 - w3 * x1 - y3 * z1 + z3 * y1;
      var y4 = y3 * w1 - w3 * y1 - z3 * x1 + x3 * z1;
      var z4 = z3 * w1 - w3 * z1 - x3 * y1 + y3 * x1;

      return [x4, y4, z4];
    }