/** * Constructs a {@link ArchimedeanSpiral3D} with the specified parameters. * * @param scale {@code double} Factor which determines the overal size of the spiral. * @param density {@code double} Factor which determines how tightly the spiral is curled. Smaller values result in tighter curling. * @param start {@link Vector3} The point where the spiral should start from. * @param normal {@link Vector3} The normal vector of the plane the spiral is in. This is assumed to be * orthogonal to the vector formed from the start to the origin. * @param spiralIn {@code boolean} True if the spiral should move from the staring point in. False to move from starting point out. * Note that for an Archimedean spiral, inward spiraling is not infinite as is the case for a logarithmic * spiral. A sufficient number of rotations will cause a "loop" to form and it will begin spiraling outward. */ public ArchimedeanSpiral3D(double scale, double density, Vector3 start, Vector3 normal, boolean spiralIn) { super(density, start, normal, spiralIn); // Calculate the remaining conditions a = scale; mInvDensity = 1.0 / mDensity; // Calculate the starting offset mThetaOffset = mSpiralIn ? calculateThetaForRadius(mStart.length()) : mRotation.getXAxis().angle(mStart); }
/** * Constructs a {@link LogarithmicSpiral3D} with the specified parameters. * * @param density {@code double} Factor which determines how tightly the spiral is curled. Larger values result in tighter curling. * @param start {@link Vector3} The point where the spiral should start from. * @param normal {@link Vector3} The normal vector of the plane the spiral is in. This is assumed to be * orthogonal to the vector formed from the start to the origin. * @param spiralIn {@code boolean} True if the spiral should move from the staring point in. False to move from starting point out. */ public LogarithmicSpiral3D(double density, Vector3 start, Vector3 normal, boolean spiralIn) { super(density, start, normal, spiralIn); // Calculate the remaining conditions a = mStart.length(); // Calculate the starting offset mThetaOffset = mSpiralIn ? calculateThetaForRadius(mStart.length()) : mRotation.getXAxis().angle(mStart); }
@Test public void testAngle() { final Vector3 v1 = new Vector3(Vector3.X); final Vector3 v2 = new Vector3(Vector3.Y); final Vector3 v = new Vector3(1d, 1d, 1d); final double angle1 = v1.angle(v2); final double angle2 = v2.angle(v1); assertEquals(90d, angle1, 0d); assertEquals(90d, angle2, 0d); assertEquals(54.735610317245346, v.angle(Vector3.X), 1e-14); assertEquals(54.735610317245346, v.angle(Vector3.Y), 1e-14); assertEquals(54.735610317245346, v.angle(Vector3.Z), 1e-14); }
public boolean isLookingAtObject(Object3D target, float maxAngle) { mHeadViewQuaternion.fromMatrix(mHeadViewMatrix); mHeadViewQuaternion.inverse(); mForwardVec.setAll(0, 0, 1); mForwardVec.rotateBy(mHeadViewQuaternion); mHeadTranslation.setAll(mHeadViewMatrix.getTranslation()); mHeadTranslation.subtract(target.getPosition()); mHeadTranslation.normalize(); return mHeadTranslation.angle(mForwardVec) < maxAngle; } }
/** * Constructs a {@link ArchimedeanSpiral3D} with the specified parameters. * * @param scale {@code double} Factor which determines the overal size of the spiral. * @param density {@code double} Factor which determines how tightly the spiral is curled. Smaller values result in tighter curling. * @param start {@link Vector3} The point where the spiral should start from. * @param normal {@link Vector3} The normal vector of the plane the spiral is in. This is assumed to be * orthogonal to the vector formed from the start to the origin. * @param spiralIn {@code boolean} True if the spiral should move from the staring point in. False to move from starting point out. * Note that for an Archimedean spiral, inward spiraling is not infinite as is the case for a logarithmic * spiral. A sufficient number of rotations will cause a "loop" to form and it will begin spiraling outward. */ public ArchimedeanSpiral3D(double scale, double density, Vector3 start, Vector3 normal, boolean spiralIn) { super(density, start, normal, spiralIn); // Calculate the remaining conditions a = scale; mInvDensity = 1.0 / mDensity; // Calculate the starting offset mThetaOffset = mSpiralIn ? calculateThetaForRadius(mStart.length()) : mRotation.getXAxis().angle(mStart); }
/** * Constructs a {@link LogarithmicSpiral3D} with the specified parameters. * * @param density {@code double} Factor which determines how tightly the spiral is curled. Larger values result in tighter curling. * @param start {@link Vector3} The point where the spiral should start from. * @param normal {@link Vector3} The normal vector of the plane the spiral is in. This is assumed to be * orthogonal to the vector formed from the start to the origin. * @param spiralIn {@code boolean} True if the spiral should move from the staring point in. False to move from starting point out. */ public LogarithmicSpiral3D(double density, Vector3 start, Vector3 normal, boolean spiralIn) { super(density, start, normal, spiralIn); // Calculate the remaining conditions a = mStart.length(); // Calculate the starting offset mThetaOffset = mSpiralIn ? calculateThetaForRadius(mStart.length()) : mRotation.getXAxis().angle(mStart); }