-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03b8d99
commit 013badb
Showing
3 changed files
with
131 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ of this software and associated documentation files (the "Software"), to deal | |
* | ||
* @author Stephen Gold [email protected] | ||
*/ | ||
final public class RVec3 { | ||
final public class RVec3 implements RVec3Arg { | ||
// ************************************************************************* | ||
// fields | ||
|
||
|
@@ -70,12 +70,28 @@ public RVec3(double x, double y, double z) { | |
// ************************************************************************* | ||
// new methods exposed | ||
|
||
/** | ||
* Set all 3 components to specified values. | ||
* | ||
* @param x the desired X component | ||
* @param y the desired Y component | ||
* @param z the desired Z component | ||
*/ | ||
public void set(double x, double y, double z) { | ||
this.xx = x; | ||
this.yy = y; | ||
this.zz = z; | ||
} | ||
// ************************************************************************* | ||
// RVec3Arg methods | ||
|
||
/** | ||
* Return the first (X) component at positional precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public Object getX() { | ||
Object result; | ||
if (Jolt.isDoublePrecision()) { | ||
|
@@ -93,6 +109,7 @@ public Object getX() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public Object getY() { | ||
Object result; | ||
if (Jolt.isDoublePrecision()) { | ||
|
@@ -110,6 +127,7 @@ public Object getY() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public Object getZ() { | ||
Object result; | ||
if (Jolt.isDoublePrecision()) { | ||
|
@@ -121,25 +139,13 @@ public Object getZ() { | |
return result; | ||
} | ||
|
||
/** | ||
* Set all 3 components to specified values. | ||
* | ||
* @param x the desired X component | ||
* @param y the desired Y component | ||
* @param z the desired Z component | ||
*/ | ||
public void set(double x, double y, double z) { | ||
this.xx = x; | ||
this.yy = y; | ||
this.zz = z; | ||
} | ||
|
||
/** | ||
* Return the first (X) component in single precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public float x() { | ||
return (float) xx; | ||
} | ||
|
@@ -150,6 +156,7 @@ public float x() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public double xx() { | ||
return xx; | ||
} | ||
|
@@ -160,6 +167,7 @@ public double xx() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public float y() { | ||
return (float) yy; | ||
} | ||
|
@@ -170,6 +178,7 @@ public float y() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public double yy() { | ||
return yy; | ||
} | ||
|
@@ -180,6 +189,7 @@ public double yy() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public float z() { | ||
return (float) zz; | ||
} | ||
|
@@ -190,6 +200,7 @@ public float z() { | |
* | ||
* @return the component value | ||
*/ | ||
@Override | ||
public double zz() { | ||
return zz; | ||
} | ||
|
104 changes: 104 additions & 0 deletions
104
src/main/java/com/github/stephengold/joltjni/RVec3Arg.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
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 RVec3} instances. | ||
* | ||
* @author Stephen Gold [email protected] | ||
*/ | ||
public interface RVec3Arg { | ||
// ************************************************************************* | ||
// new methods exposed | ||
|
||
/** | ||
* Return the first (X) component at positional precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
Object getX(); | ||
|
||
/** | ||
* Return the 2nd (Y) component at positional precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
Object getY(); | ||
|
||
/** | ||
* Return the 3rd (Z) component at positional precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
Object getZ(); | ||
|
||
/** | ||
* Return the first (X) component in single precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
float x(); | ||
|
||
/** | ||
* Return the first (X) component in double precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
double xx(); | ||
|
||
/** | ||
* Return the 2nd (Y) component in single precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
float y(); | ||
|
||
/** | ||
* Return the 2nd (Y) component in double precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
double yy(); | ||
|
||
/** | ||
* Return the 3rd (Z) component in single precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
float z(); | ||
|
||
/** | ||
* Return the 3rd (Z) component in double precision. The vector is | ||
* unaffected. | ||
* | ||
* @return the component value | ||
*/ | ||
double zz(); | ||
} |