public Tuple3 CenterOfMass(ReferenceFrame referenceFrame) { if (ReferenceEquals(referenceFrame, null)) { throw new ArgumentNullException("referenceFrame"); } return(referenceFrame.PositionFromWorldSpace(InternalPart.CenterOfMass()).ToTuple()); }
public Tuple3 Position(ReferenceFrame referenceFrame) { if (ReferenceEquals(referenceFrame, null)) { throw new ArgumentNullException(nameof(referenceFrame)); } return(referenceFrame.PositionFromWorldSpace(InternalPart.transform.position).ToTuple()); }
public Tuple3 Position(ReferenceFrame referenceFrame) { if (ReferenceEquals(referenceFrame, null)) { throw new ArgumentNullException("referenceFrame"); } return(referenceFrame.PositionFromWorldSpace(port.nodeTransform.position).ToTuple()); }
/// <summary> /// Computes the axis-aligned bounding box for a part in the given reference frame. /// </summary> /// <remarks> /// This is an expensive calculation. It iterates over the parts collider meshes /// to compute a tight axis-aligned bounding box. /// It does not use part.collider.bounds, as this is aligned to world space and /// would not provide a tight bounding box in the given reference frame. /// </remarks> public static Bounds GetBounds(this Part part, ReferenceFrame referenceFrame) { var colliders = part.GetComponentsInChildren <MeshCollider> (); var bounds = new Bounds(referenceFrame.PositionFromWorldSpace(part.WCoM), Vector3.zero); foreach (var collider in colliders) { var vertices = collider.sharedMesh.bounds.ToVertices(); for (int i = 0; i < vertices.Length; i++) { // part space -> world space -> reference frame space var vertex = referenceFrame.PositionFromWorldSpace(collider.transform.TransformPoint(vertices [i])); bounds.Encapsulate(vertex); } } return(bounds); }
/// <summary> /// Computes the axis-aligned bounding box for a part in the given reference frame. /// </summary> /// <remarks> /// This is an expensive calculation. It iterates over the parts collider meshes /// to compute a tight axis-aligned bounding box. /// It does not use part.collider.bounds, as this is aligned to world space and /// would not provide a tight bounding box in the given reference frame. /// </remarks> public static Bounds GetBounds(this Part part, ReferenceFrame referenceFrame) { var bounds = new Bounds(referenceFrame.PositionFromWorldSpace(part.WCoM), Vector3.zero); var meshes = part.GetComponentsInChildren <MeshFilter> (); for (int i = 0; i < meshes.Length; i++) { var mesh = meshes [i]; var vertices = mesh.mesh.bounds.ToVertices(); for (int j = 0; j < vertices.Length; j++) { // mesh space -> world space -> reference frame space var vertex = referenceFrame.PositionFromWorldSpace(mesh.transform.TransformPoint(vertices [j])); bounds.Encapsulate(vertex); } } return(bounds); }
public Tuple3 GimbalPosition(ReferenceFrame referenceFrame) { if (ReferenceEquals(referenceFrame, null)) { throw new ArgumentNullException(nameof(referenceFrame)); } CheckGimballed(); return(referenceFrame.PositionFromWorldSpace(gimbal.gimbalTransforms [transformIndex].position).ToTuple()); }
public Tuple3 InitialThrustPosition(ReferenceFrame referenceFrame) { if (ReferenceEquals(referenceFrame, null)) { throw new ArgumentNullException(nameof(referenceFrame)); } StashGimbalRotation(); var position = WorldTransform.position; RestoreGimbalRotation(); return(referenceFrame.PositionFromWorldSpace(position).ToTuple()); }
public static Tuple3 TransformPosition (Tuple3 position, ReferenceFrame from, ReferenceFrame to) { CheckReferenceFrames (from, to); return to.PositionFromWorldSpace (from.PositionToWorldSpace (position.ToVector ())).ToTuple (); }
public Tuple3 Position(ReferenceFrame referenceFrame) { return(referenceFrame.PositionFromWorldSpace(InternalPart.transform.position).ToTuple()); }
public Tuple3 Position(ReferenceFrame referenceFrame) { return(referenceFrame.PositionFromWorldSpace(port.nodeTransform.position).ToTuple()); }