diff --git a/src/main/java/com/github/stephengold/joltjni/BodyCreationSettings.java b/src/main/java/com/github/stephengold/joltjni/BodyCreationSettings.java index 793db7bb..c71a0d34 100644 --- a/src/main/java/com/github/stephengold/joltjni/BodyCreationSettings.java +++ b/src/main/java/com/github/stephengold/joltjni/BodyCreationSettings.java @@ -39,8 +39,8 @@ public class BodyCreationSettings extends JoltPhysicsObject { * @param motionType the desired motion type (not null) * @param objLayer the ID of the desired object layer */ - public BodyCreationSettings(Shape shape, - RVec3Arg loc, Quat orient, EMotionType motionType, int objLayer) { + public BodyCreationSettings(Shape shape, RVec3Arg loc, QuatArg orient, + EMotionType motionType, int objLayer) { long shapeVa = shape.va(); int motionTypeOrdinal = motionType.ordinal(); long bodySettingsVa = createBodyCreationSettingsFromShape( @@ -59,8 +59,8 @@ public BodyCreationSettings(Shape shape, * @param motionType the desired motion type (not null) * @param objLayer the ID of the desired object layer */ - public BodyCreationSettings(ShapeSettings shapeSettings, - RVec3Arg loc, Quat orient, EMotionType motionType, int objLayer) { + public BodyCreationSettings(ShapeSettings shapeSettings, RVec3Arg loc, + QuatArg orient, EMotionType motionType, int objLayer) { long shapeSettingsVa = shapeSettings.va(); int motionTypeOrdinal = motionType.ordinal(); long bodySettingsVa = createBodyCreationSettingsFromShapeSettings( diff --git a/src/main/java/com/github/stephengold/joltjni/Quat.java b/src/main/java/com/github/stephengold/joltjni/Quat.java index 776029b6..7203e0a3 100644 --- a/src/main/java/com/github/stephengold/joltjni/Quat.java +++ b/src/main/java/com/github/stephengold/joltjni/Quat.java @@ -31,7 +31,7 @@ of this software and associated documentation files (the "Software"), to deal * * @author Stephen Gold sgold@sonic.net */ -final public class Quat { +final public class Quat implements QuatArg { // ************************************************************************* // fields @@ -95,6 +95,8 @@ public void set(float x, float y, float z, float w) { this.z = z; this.w = w; } + // ************************************************************************* + // QuatArg methods /** * Return the real (W) component in single precision. The quaternion is @@ -102,6 +104,7 @@ public void set(float x, float y, float z, float w) { * * @return the component value */ + @Override public float getW() { return w; } @@ -112,6 +115,7 @@ public float getW() { * * @return the component value */ + @Override public float getX() { return x; } @@ -122,6 +126,7 @@ public float getX() { * * @return the component value */ + @Override public float getY() { return y; } @@ -132,6 +137,7 @@ public float getY() { * * @return the component value */ + @Override public float getZ() { return z; } diff --git a/src/main/java/com/github/stephengold/joltjni/QuatArg.java b/src/main/java/com/github/stephengold/joltjni/QuatArg.java new file mode 100644 index 00000000..1f66846b --- /dev/null +++ b/src/main/java/com/github/stephengold/joltjni/QuatArg.java @@ -0,0 +1,64 @@ +/* +Copyright (c) 2024 Stephen Gold + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + */ +package com.github.stephengold.joltjni; + +/** + * A read-only interface to {@code Quat} instances. + * + * @author Stephen Gold sgold@sonic.net + */ +public interface QuatArg { + // ************************************************************************* + // new methods exposed + + /** + * Return the real (W) component in single precision. The quaternion is + * unaffected. + * + * @return the component value + */ + float getW(); + + /** + * Return the first imaginary (X) component in single precision. The + * quaternion is unaffected. + * + * @return the component value + */ + float getX(); + + /** + * Return the 2nd imaginary (Y) component in single precision. The + * quaternion is unaffected. + * + * @return the component value + */ + float getY(); + + /** + * Return the 3rd imaginary (Z) component in single precision. The + * quaternion is unaffected. + * + * @return the component value + */ + float getZ(); +}