| | | 1 | | //======================================================================= |
| | | 2 | | // JointFrame3D.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2026-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using FixedMathSharp; |
| | | 9 | | |
| | | 10 | | namespace Gravitas.Constraints; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Immutable local anchor frame used by a 3D joint. |
| | | 14 | | /// </summary> |
| | | 15 | | public readonly struct JointFrame3D |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Creates a local joint frame. |
| | | 19 | | /// </summary> |
| | | 20 | | public JointFrame3D(Vector3d position, FixedQuaternion rotation) |
| | | 21 | | { |
| | 634 | 22 | | Position = position; |
| | 634 | 23 | | Rotation = rotation.Normalized; |
| | 634 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Gets the local anchor position relative to the linked body. |
| | | 28 | | /// </summary> |
| | | 29 | | public Vector3d Position { get; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Gets the local anchor orientation relative to the linked body. |
| | | 33 | | /// </summary> |
| | | 34 | | public FixedQuaternion Rotation { get; } |
| | | 35 | | |
| | | 36 | | internal static JointFrame3D FromTransform(FixedTransform transform, string parameterName) |
| | | 37 | | { |
| | 624 | 38 | | SwiftThrowHelper.ThrowIfNull(transform, parameterName); |
| | 624 | 39 | | return new JointFrame3D(transform.LocalPosition, transform.LocalRotation); |
| | | 40 | | } |
| | | 41 | | } |