matrix.setRotation( new AxisAngle4f( 0, 1, 0, rotation ) );
public static void getAxisAngle(int index, AxisAngle4f axisAngle) { axisAngle.set(orientations.get(index)); }
/** * Return rotation in AxisAngle form. * * @param axisAngle */ public void getRotation(AxisAngle4f axisAngle) { axisAngle.setX((float) (mat21 - mat12)); axisAngle.setY((float) (mat02 - mat20)); axisAngle.setZ((float) (mat10 - mat01)); double mag = axisAngle.getX() * axisAngle.getX() + axisAngle.getY() * axisAngle.getY() + axisAngle.getZ() * axisAngle.getZ(); if (mag > 1.0e-12) { mag = Math.sqrt(mag); double sin = 0.5 * mag; double cos = 0.5 * (mat00 + mat11 + mat22 - 1.0); axisAngle.setAngle((float) Math.atan2(sin, cos)); double invMag = 1.0 / mag; axisAngle.setX((float) (axisAngle.getX() * invMag)); axisAngle.setY((float) (axisAngle.getY() * invMag)); axisAngle.setZ((float) (axisAngle.getZ() * invMag)); } else { axisAngle.setX((float) 0.0); axisAngle.setY((float) 1.0); axisAngle.setZ((float) 0.0); axisAngle.setAngle((float) 0.0); } }
axisAngle.setX((float) (rot21 - rot12)); axisAngle.setY((float) (rot02 - rot20)); axisAngle.setZ((float) (rot10 - rot01)); double mag = axisAngle.getX() * axisAngle.getX() + axisAngle.getY() * axisAngle.getY() + axisAngle.getZ() * axisAngle.getZ(); double cos = 0.5 * (rot00 + rot11 + rot22 - 1.0); axisAngle.setAngle((float) Math.atan2(sin, cos)); axisAngle.setX((float) (axisAngle.getX() * invMag)); axisAngle.setY((float) (axisAngle.getY() * invMag)); axisAngle.setZ((float) (axisAngle.getZ() * invMag)); axisAngle.setX((float) 0.0); axisAngle.setY((float) 1.0); axisAngle.setZ((float) 0.0); axisAngle.setAngle((float) 0.0);
public TrajectoireCamera(final int _nbCles, final BUniversInterface _u, final boolean _boucle, final int _temps, final int _nbCycles) { univers_ = _u; boucle_ = _boucle; nbCles_ = _nbCles; if (boucle_) { pourcentAtIndex_ = new float[nbCles_ + 1]; positions_ = new Point3f[nbCles_ + 1]; directions_ = new Quat4f[nbCles_ + 1]; } else { pourcentAtIndex_ = new float[nbCles_]; positions_ = new Point3f[nbCles_]; directions_ = new Quat4f[nbCles_]; } temps_ = _temps; nbCycles_ = _nbCycles; axe_ = new Transform3D(); axe_.set(new AxisAngle4f(1f, 0f, 0f, 0f)); }
double mag = Math.sqrt(axisAngle.getX() * axisAngle.getX() + axisAngle.getY() * axisAngle.getY() + axisAngle.getZ() * axisAngle.getZ()); double ax = axisAngle.getX() * mag; double ay = axisAngle.getY() * mag; double az = axisAngle.getZ() * mag; double sinTheta = Math.sin(axisAngle.getAngle()); double cosTheta = Math.cos(axisAngle.getAngle()); double t = 1.0 - cosTheta;
public static void convertMatrixToAxisAngle(Matrix3f rotationMatrix, AxisAngle4f axisAngle4fToPack) { Quat4d quat4d = threadLocalTemporaryQuaternion.get(); Matrix3d rotationMatrixDouble = rotationMatrixForConvertingFloatToDouble.get(); rotationMatrixDouble.set(rotationMatrix); convertMatrixToQuaternion(rotationMatrixDouble, quat4d); axisAngle4fToPack.set(quat4d); }
@Nonnull @Override @SideOnly(Side.CLIENT) public Pair<IBakedModel, Matrix4f> getModel(float delta) { Matrix4f matrix = new Matrix4f(); matrix.setIdentity(); matrix.setRotation(new AxisAngle4f(0f, 1f, 0f, delta)); IBakedModel model = this.model; if (model == null) { model = this.model = RenderHelpers.getMesher().getItemModel(new ItemStack(item)); } return Pair.of(model, matrix); }
double mag = Math.sqrt(axisAngle.getX() * axisAngle.getX() + axisAngle.getY() * axisAngle.getY() + axisAngle.getZ() * axisAngle.getZ()); double ax = axisAngle.getX() / mag; double ay = axisAngle.getY() / mag; double az = axisAngle.getZ() / mag; double sTheta = Math.sin(axisAngle.getAngle()); double cTheta = Math.cos(axisAngle.getAngle()); double t = 1.0 - cTheta;
private static Multimap<Orientation, XYZRotation> calculateXyzRotations(Map<Matrix3f, Orientation> fromMatrix) { final Multimap<Orientation, XYZRotation> toXYZRotation = HashMultimap.create(); for (Rotation x : Rotation.values()) for (Rotation y : Rotation.values()) for (Rotation z : Rotation.values()) { final XYZRotation rotation = new XYZRotation(x, y, z); Quat4f q = new Quat4f(0, 0, 0, 1); Quat4f tmp = new Quat4f(); tmp.set(new AxisAngle4f(0, 0, 1, z.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(0, 1, 0, y.angle)); q.mul(tmp); tmp.set(new AxisAngle4f(1, 0, 0, x.angle)); q.mul(tmp); Matrix3f m = new Matrix3f(); m.set(q); roundMatrixElements(m); final Orientation orientation = fromMatrix.get(m); Preconditions.checkNotNull(orientation, rotation); toXYZRotation.put(orientation, rotation); } return toXYZRotation; }
double mag = Math.sqrt(axisAngle.getX() * axisAngle.getX() + axisAngle.getY() * axisAngle.getY() + axisAngle.getZ() * axisAngle.getZ()); double ax = axisAngle.getX() / mag; double ay = axisAngle.getY() / mag; double az = axisAngle.getZ() / mag; double sTheta = Math.sin(axisAngle.getAngle()); double cTheta = Math.cos(axisAngle.getAngle()); double t = 1.0 - cTheta;
@Nonnull @Override @SideOnly(Side.CLIENT) public Pair<IBakedModel, Matrix4f> getModel(float delta) { Matrix4f matrix = new Matrix4f(); matrix.setIdentity(); // We flip the laser so it points forwards on turtles. if (stack.getItemDamage() == LASER_ID) { delta = (float) ((delta + Math.PI) % (2 * Math.PI)); } matrix.setRotation(new AxisAngle4f(0f, 1f, 0f, delta)); return Pair.of( RenderHelpers.getMesher().getItemModel(stack), matrix ); } }
double mag = Math.sqrt(axisAngle.getX() * axisAngle.getX() + axisAngle.getY() * axisAngle.getY() + axisAngle.getZ() * axisAngle.getZ()); double ax = axisAngle.getX() / mag; double ay = axisAngle.getY() / mag; double az = axisAngle.getZ() / mag; double sTheta = Math.sin(axisAngle.getAngle()); double cTheta = Math.cos(axisAngle.getAngle()); double t = 1.0 - cTheta;
private static Vector3d rotate(Vector3d vector, Vector3d axis, double angle) { Matrix3f rotate = new Matrix3f(); rotate.set(new AxisAngle4f(new Vector3f(axis), (float) Math.toRadians(angle))); Vector3f result = new Vector3f(); Vector3f vector3f = new Vector3f(vector); rotate.transform(vector3f, result); return new Vector3d(result); }
private static Vector3d rotate(Vector3d vector, Vector3d axis, double angle) { Matrix3f rotate = new Matrix3f(); rotate.set(new AxisAngle4f(new Vector3f(axis), (float) Math.toRadians(angle))); Vector3f result = new Vector3f(); Vector3f vector3f = new Vector3f(vector); rotate.transform(vector3f, result); return new Vector3d(result); }
rot.setRotation(new AxisAngle4f(cross.getX(),cross.getY(),cross.getZ(),angle)); tx.mul(rot);