Explode a scene around a point and vector.

        Parameters
        -----------
        vector : (3,) float or float
           Explode radially around a direction vector or spherically
        origin : (3,) float
          Point to explode around
427133
def explode(self, vector=None, origin=None):
        
        if origin is None:
            origin = self.centroid
        if vector is None:
            vector = self.scale / 25.0

        vector = np.asanyarray(vector, dtype=np.float64)
        origin = np.asanyarray(origin, dtype=np.float64)

        for node_name in self.graph.nodes_geometry:
            transform, geometry_name = self.graph[node_name]

            centroid = self.geometry[geometry_name].centroid
            # transform centroid into nodes location
            centroid = np.dot(transform,
                              np.append(centroid, 1))[:3]

            if vector.shape == ():
                # case where our vector is a single number
                offset = (centroid - origin) * vector
            elif np.shape(vector) == (3,):
                projected = np.dot(vector, (centroid - origin))
                offset = vector * projected
            else:
                raise ValueError('explode vector wrong shape!')

            transform[0:3, 3] += offset
            self.graph[node_name] = transform
717088
def vector(p1, p2):
    
    return None if len(p1) != len(p2) else np.array([p2[i] - p1[i] for i in range(len(p1))])
229808
public Vector3f orthogonalize(Vector3fc v, Vector3f dest) {
        /*
         * http://lolengine.net/blog/2013/09/21/picking-orthogonal-vector-combing-coconuts
         */
        float rx, ry, rz;
        if (Math.abs(v.x()) > Math.abs(v.z())) {
            rx = -v.y();
            ry = v.x();
            rz = 0.0f;
        } else {
            rx = 0.0f;
            ry = -v.z();
            rz = v.y();
        }
        float invLen = 1.0f / (float) Math.sqrt(rx * rx + ry * ry + rz * rz);
        dest.x = rx * invLen;
        dest.y = ry * invLen;
        dest.z = rz * invLen;
        return dest;
    }
168845
def from_scene_coords(self, x=0, y=0):
        """"""
        matrix = self.get_matrix()
        matrix.invert()
        return matrix.transform_point(x, y)
369703
function( pointA, pointB ) {

	        var vector = _getVector( pointA, pointB );
	        return -Crafty.math.radToDeg( Math.atan2( vector.y, vector.x ) ).toFixed( 3 );
	    }
551962
function(obj) {
    if (obj.anchor) {
      // obj is a plane or line
      var P = this.elements.slice();
      var C = obj.pointClosestTo(P).elements;
      return Vector.create([C[0] + (C[0] - P[0]), C[1] + (C[1] - P[1]), C[2] + (C[2] - (P[2] || 0))]);
    } else {
      // obj is a point
      var Q = obj.elements || obj;
      if (this.elements.length != Q.length) { return null; }
      return this.map(function(x, i) { return Q[i-1] + (Q[i-1] - x); });
    }
  }
714839
function _Vector(dimension, data) {
  if (!dimension || !Number.isInteger(dimension))
    throw new TypeError('Dimension of the array must be an integer.');

  var _values;
  if (!data || data === undefined)
    _values = [];
  else if (!util.isNumberArray(data))
    throw new TypeError('Invalid values for vector.');
  else
    _values = data;

  if (_values.length < dimension) {
    var zeros = Array(dimension - _values.length).fill(0);
    _values = _values.concat(zeros);
  } else if (_values.length > dimension) {
    _values = _values.slice(0, dimension);
  }

  readonly(this, "dimension", dimension);
  readonly(this, "values", _values);
  readonly(this, "magnitude", _magnitudeOf(_values));
}
1006126
def prepare(vector)
      vertex = vector.normalize.clone
      vertex.index = @vertices.push(vertex).length - 1

      # Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle.
      u = azimuth(vector) / 2.0 / Math::PI + 0.5
      v = inclination(vector) / Math::PI + 0.5
      vertex.uv = Vector2.new(u, 1.0 - v)

      vertex
    end
168828
def attack_vectors(color = @player_turn, proposed_manifest = @piece_locations)
      enemy_color = opposing_color(color)
      kill_zone = []

      proposed_manifest.each do |piece, details|
        kill_zone << possible_moves(piece, proposed_manifest) if details.fetch(:color) == enemy_color
      end

      kill_zone.flatten.uniq
    end
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
298159
function (ray) {
        Vector3.copy(this.origin, ray.origin);
        Vector3.copy(this.direction, ray.direction);
    }
592983
def rotate_vec(self, vec):
        
        xyz = Vec3(self.x, self.y, self.z)
        return add_v3(vec, scale_v3(
            xyz.cross(xyz.cross(vec) + scale_v3(vec, self.w)), 2.0))
971000
def vectors(self, pos, vel, roll=0.0, pitch=0.0, yaw=0.0):
        
        # TODO: yaw steering mode !

        # Fake nadir: This is the intersection point between the satellite
        # looking down at the centre of the ellipsoid and the surface of the
        # ellipsoid. Nadir on the other hand is the point which vertical goes
        # through the satellite...
        # nadir = -pos / vnorm(pos)

        nadir = subpoint(-pos)
        nadir /= vnorm(nadir)

        # x is along track (roll)
        x = vel / vnorm(vel)

        # y is cross track (pitch)
        y = np.cross(nadir, vel, 0, 0, 0)
        y /= vnorm(y)

        # rotate first around x
        x_rotated = qrotate(nadir, x, self.fovs[0] + roll)
        # then around y
        xy_rotated = qrotate(x_rotated, y, self.fovs[1] + pitch)
        # then around z
        return qrotate(xy_rotated, nadir, yaw)
844372
def dot(rhs)
      Util3D.check_arg_type(Vector3, rhs)
      self.x*rhs.x + self.y*rhs.y + self.z*rhs.z
    end
240963
function(point, out) {
        if (!out) {
            out = new Vector3();
        }
        var d = this.distanceToPoint(point);
        vec3.scaleAndAdd(out.array, point.array, this.normal.array, -d);
        out._dirty = true;
        return out;
    }
605942
def uv_parameter(check_point)
      Util3D.check_arg_type(::Vector3, check_point)
      mat = Matrix[[u_vector.x, u_vector.y, u_vector.z],
            [v_vector.x, v_vector.y, v_vector.z],
            [normal.x, normal.y, normal.z]]
      vec = (check_point - base_point).to_column_vector
      ans = mat.t.inv*vec
      return ans[0,0], ans[1,0]
    end
707636
function (plane, rightvector) {
  if (arguments.length < 2) {
    // choose an arbitrary right hand vector, making sure it is somewhat orthogonal to the plane normal:
    rightvector = vec3.random(plane)
  } else {
    rightvector = rightvector
  }
  this.v = vec3.unit(vec3.cross(plane, rightvector))
  this.u = vec3.cross(this.v, plane)
  this.plane = plane
  this.planeorigin = vec3.scale(plane[3], plane)
}