private Vector3 calculateFaceNormal(int[] vertexIDs) { ArrayList<Vector3> vertices = mVertices.get(mObjects); Vector3 v1 = vertices.get(vertexIDs[0]); Vector3 v2 = vertices.get(vertexIDs[2]); Vector3 v3 = vertices.get(vertexIDs[1]); Vector3 vector1 = Vector3.subtractAndCreate(v2, v1); Vector3 vector2 = Vector3.subtractAndCreate(v3, v1); Vector3 normal = Vector3.crossAndCreate(vector1, vector2); normal.normalize(); return normal; }
/** * Constructs a {@link ArchimedeanSpiral3D} with the specified parameters. * * @param density {@code double} Factor which determines how tightly the spiral is curled. * @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 ASpiral3D(double density, Vector3 start, Vector3 normal, boolean spiralIn) { // Store the provided initial conditions mSpiralIn = spiralIn; mDensity = density; mStart = Vector3.subtractAndCreate(start, Vector3.ZERO); mUp = normal.clone(); // Calculate the remaining conditions mCalculateTangents = false; // Create the initial tangent vector mCurrentTangent = Vector3.crossAndCreate(mStart, mUp); // The initial rotation is 0 radians about the up axis mRotation = new Quaternion(mUp, 0); }
@Test public void testCrossAndCreate() { final Vector3 u = new Vector3(1d, 2d, 3d); final Vector3 v = new Vector3(4d, 5d, 6d); final Vector3 t = Vector3.crossAndCreate(u, v); assertNotNull(t); assertEquals(-3d, t.x, 0); assertEquals(6d, t.y, 0); assertEquals(-3d, t.z, 0); }
Vector3 vector2 = Vector3.subtractAndCreate(v3, v1); normal = Vector3.crossAndCreate(vector1, vector2); normal.normalize();
Vector3 v2 = new Vector3(mesh.vertices[index23], mesh.vertices[index23 + 1], mesh.vertices[index23 + 2]); Vector3 normal = Vector3.crossAndCreate(Vector3.subtractAndCreate(v2, v0), Vector3.subtractAndCreate(v1, v0)); normal.inverse();
private Vector3 calculateFaceNormal(int[] vertexIDs) { ArrayList<Vector3> vertices = mVertices.get(mObjects); Vector3 v1 = vertices.get(vertexIDs[0]); Vector3 v2 = vertices.get(vertexIDs[2]); Vector3 v3 = vertices.get(vertexIDs[1]); Vector3 vector1 = Vector3.subtractAndCreate(v2, v1); Vector3 vector2 = Vector3.subtractAndCreate(v3, v1); Vector3 normal = Vector3.crossAndCreate(vector1, vector2); normal.normalize(); return normal; }
Vector3 semiminorAxis = Vector3.crossAndCreate(new Vector3(unitSemiMajorAxis_x, unitSemiMajorAxis_y, unitSemiMajorAxis_z), new Vector3(normalCenter_x, normalCenter_y, normalCenter_z)); semiminorAxis.multiply(b);
/** * Constructs a {@link ArchimedeanSpiral3D} with the specified parameters. * * @param density {@code double} Factor which determines how tightly the spiral is curled. * @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 ASpiral3D(double density, Vector3 start, Vector3 normal, boolean spiralIn) { // Store the provided initial conditions mSpiralIn = spiralIn; mDensity = density; mStart = Vector3.subtractAndCreate(start, Vector3.ZERO); mUp = normal.clone(); // Calculate the remaining conditions mCalculateTangents = false; // Create the initial tangent vector mCurrentTangent = Vector3.crossAndCreate(mStart, mUp); // The initial rotation is 0 radians about the up axis mRotation = new Quaternion(mUp, 0); }
Vector3 axis = Vector3.crossAndCreate(Vector3.getAxisVector(Axis.X), this); if (axis.length() == 0) // pick another if colinear axis = Vector3.crossAndCreate(Vector3.getAxisVector(Axis.Y), this); axis.normalize(); q.fromAngleAxis(axis, MathUtil.radiansToDegrees(MathUtil.PI)); double invs = 1 / s; Vector3 c = Vector3.crossAndCreate(v0, v1);
Vector3 vector2 = Vector3.subtractAndCreate(v3, v1); normal = Vector3.crossAndCreate(vector1, vector2); normal.normalize();
Vector3 v2 = new Vector3(mesh.vertices[index23], mesh.vertices[index23 + 1], mesh.vertices[index23 + 2]); Vector3 normal = Vector3.crossAndCreate(Vector3.subtractAndCreate(v2, v0), Vector3.subtractAndCreate(v1, v0)); normal.inverse();