Return the crossproduct between vec_a and vec_b.
343042
def cross_v3(vec_a, vec_b):
    """"""

    return Vec3(vec_a.y * vec_b.z - vec_a.z * vec_b.y,
                vec_a.z * vec_b.x - vec_a.x * vec_b.z,
                vec_a.x * vec_b.y - vec_a.y * vec_b.x)
103962
def cross(triangles):
    
    vectors = np.diff(triangles, axis=1)
    crosses = np.cross(vectors[:, 0], vectors[:, 1])
    return crosses
890454
function vecSub(a, b) {

  return [
  new Fraction(a[0]).sub(b[0]),
  new Fraction(a[1]).sub(b[1])
  ];
}
1103579
def lines_intersect(pt1_p, pt2_p, pt1_q, pt2_q):
    '''
    '''
    #
    # The idea here is to do the cross-product of the vector from
    # point 1 to point 2 of one segment against the cross products from 
    # both points of the other segment. If any of the cross products are zero,
    # the point is colinear with the line. If the cross products differ in
    # sign, then one point is on one side of the line and the other is on
    # the other. If that happens for both, then the lines must cross.
    #
    for pt1_a, pt2_a, pt1_b, pt2_b in ((pt1_p, pt2_p, pt1_q, pt2_q),
                                       (pt1_q, pt2_q, pt1_p, pt2_p)):
        v_a = pt2_a-pt1_a
        cross_a_1b = np.cross(v_a, pt1_b-pt2_a)
        if cross_a_1b == 0 and colinear_intersection_test(pt1_a, pt2_a, pt1_b):
            return True
        cross_a_2b = np.cross(v_a, pt2_b-pt2_a)
        if cross_a_2b == 0 and colinear_intersection_test(pt1_a, pt2_a, pt2_b):
            return True
        if (cross_a_1b < 0) == (cross_a_2b < 0):
            return False
    return True
565171
def inner_prod(a, b)
      return (0..2).inject(0.0) { |s, i| s + a[i] * b[i] }
    rescue => e
      raise
    end
1178633
public void cross(Vector3d v1, Vector3d v2) {
        double tmpx = v1.y * v2.z - v1.z * v2.y;
        double tmpy = v1.z * v2.x - v1.x * v2.z;
        double tmpz = v1.x * v2.y - v1.y * v2.x;

        x = tmpx;
        y = tmpy;
        z = tmpz;
    }
1028465
def get_scalar_product(self, other):
        """"""
        return self.x*other.x+self.y*other.y
1316091
private static double dotProduct(DoubleVector u,
                                     DoubleVector v) {
        double dot = 0;
        for (int i = 0; i < u.length(); ++i) {
            double a = u.get(i);
            double b = v.get(i);
            dot += u.get(i) * v.get(i);
        }
        return dot;
    }
1072283
def project(vec1, vec2):
    """"""
    if isinstance(vec1, Vector3) and isinstance(vec2, Vector3) \
            or isinstance(vec1, Vector4) and isinstance(vec2, Vector4):
        return dot(vec1, vec2) / vec2.length() * vec2.normalize_copy()
    else:
        raise ValueError("vec1 and vec2 must be Vector3 or Vector4 objects.")
84877
def rotation_matrix_between_vectors(from_vec, to_vec):
    
    a, b = (trans.unit_vector(vec) for vec in (from_vec, to_vec))

    v = np.cross(a, b)
    cos = np.dot(a, b)
    if cos == -1.:
        raise ValueError("Orientation in complete opposite direction")
    v_cpm = cross_product_matrix(v)
    rot_mat = np.identity(3) + v_cpm + np.dot(v_cpm, v_cpm) * (1. / 1. + cos)
    return rot_mat
169934
def cross(self, rhs):
    

    return Vector(
      self.y * rhs.z - self.z * rhs.y,
      self.z * rhs.x - self.x * rhs.z,
      self.x * rhs.y - self.y * rhs.x)
795036
public double dotProduct(ConcatVector other) {
    if (loadedNative) {
      return dotProductNative(other);
    } else {
      double sum = 0.0f;
      for (int i = 0; i < Math.min(pointers.length, other.pointers.length); i++) {
        if (pointers[i] == null || other.pointers[i] == null) continue;
        if (sparse[i] && other.sparse[i]) {
          outer:
          for (int j = 0; j < pointers[i].length / 2; j++) {
            int sparseIndex = (int) pointers[i][j * 2];
            for (int k = 0; k < other.pointers[i].length / 2; k++) {
              int otherSparseIndex = (int) other.pointers[i][k * 2];
              if (sparseIndex == otherSparseIndex) {
                sum += pointers[i][(j * 2) + 1] * other.pointers[i][(k * 2) + 1];
                continue outer;
              }
            }
          }
        } else if (sparse[i] && !other.sparse[i]) {
          for (int j = 0; j < pointers[i].length / 2; j++) {
            int sparseIndex = (int) pointers[i][j * 2];
            if (sparseIndex >= 0 && sparseIndex < other.pointers[i].length) {
              sum += other.pointers[i][sparseIndex] * pointers[i][(j * 2) + 1];
            }
          }
        } else if (!sparse[i] && other.sparse[i]) {
          for (int j = 0; j < other.pointers[i].length / 2; j++) {
            int sparseIndex = (int) other.pointers[i][j * 2];
            if (sparseIndex >= 0 && sparseIndex < pointers[i].length) {
              sum += pointers[i][sparseIndex] * other.pointers[i][(j * 2) + 1];
            }
          }
        } else {
          for (int j = 0; j < Math.min(pointers[i].length, other.pointers[i].length); j++) {
            sum += pointers[i][j] * other.pointers[i][j];
          }
        }
      }
      return sum;
    }
  }
710267
function(out, b) {
        vec2.cross(out.array, this.array, b.array);
        out._dirty = true;
        return this;
    }
1288571
def cross(v1, v2):
    '''
    '''
    return (
        v1[1] * v2[2] - v1[2] * v2[1],
        v1[2] * v2[0] - v1[0] * v2[2],
        v1[0] * v2[1] - v1[1] * v2[0],
    )
475181
def dot(self, vec):
        """"""
        if not isinstance(vec, self.__class__):
            raise TypeError('Dot product operand must be a vector')
        return np.dot(self, vec)
1201372
private static double cross(Coordinate a1, Coordinate a2, Coordinate b1, Coordinate b2) {
		return (a2.getX() - a1.getX()) * (b2.getY() - b1.getY()) - (a2.getY() - a1.getY()) * (b2.getX() - b1.getX());
	}
1175411
def angle(vec1, vec2):
        """"""
        dotp = Vector2.dot(vec1, vec2)
        mag1 = vec1.length()
        mag2 = vec2.length()
        result = dotp / (mag1 * mag2)
        return math.acos(result)