com.badlogic.gdx.math.Quaternion.mul()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中com.badlogic.gdx.math.Quaternion.mul方法的一些代码示例,展示了Quaternion.mul的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quaternion.mul方法的具体详情如下:
包路径:com.badlogic.gdx.math.Quaternion
类名称:Quaternion
方法名:mul

Quaternion.mul介绍

[英]Multiplies the components of this quaternion with the given scalar.
[中]将此四元数的分量与给定标量相乘。

代码示例

代码示例来源:origin: libgdx/libgdx

/** Rotates along local X axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateX (float angle) {
  rotator.set(Vector3.X, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: libgdx/libgdx

/** Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the
 * specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an
 * axis perpendicular to the specified axis. </p> The swing and twist rotation can be used to reconstruct the original
 * quaternion: this = swing * twist
 * 
 * @param axisX the X component of the normalized axis for which to get the swing and twist rotation
 * @param axisY the Y component of the normalized axis for which to get the swing and twist rotation
 * @param axisZ the Z component of the normalized axis for which to get the swing and twist rotation
 * @param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis
 * @param twist will receive the twist rotation: the rotation around the specified axis
 * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a> */
public void getSwingTwist (final float axisX, final float axisY, final float axisZ, final Quaternion swing,
  final Quaternion twist) {
  final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ);
  twist.set(axisX * d, axisY * d, axisZ * d, this.w).nor();
  if (d < 0) twist.mul(-1f);
  swing.set(twist).conjugate().mulLeft(this);
}

代码示例来源:origin: libgdx/libgdx

/** Rotates along local Y axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateY (float angle) {
  rotator.set(Vector3.Y, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: libgdx/libgdx

/** Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the
 * specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an
 * axis perpendicular to the specified axis. </p> The swing and twist rotation can be used to reconstruct the original
 * quaternion: this = swing * twist
 * 
 * @param axisX the X component of the normalized axis for which to get the swing and twist rotation
 * @param axisY the Y component of the normalized axis for which to get the swing and twist rotation
 * @param axisZ the Z component of the normalized axis for which to get the swing and twist rotation
 * @param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis
 * @param twist will receive the twist rotation: the rotation around the specified axis
 * @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a> */
public void getSwingTwist (final float axisX, final float axisY, final float axisZ, final Quaternion swing,
  final Quaternion twist) {
  final float d = Vector3.dot(this.x, this.y, this.z, axisX, axisY, axisZ);
  twist.set(axisX * d, axisY * d, axisZ * d, this.w).nor();
  if (d < 0) twist.mul(-1f);
  swing.set(twist).conjugate().mulLeft(this);
}

代码示例来源:origin: libgdx/libgdx

/** Rotates along local Z axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateZ (float angle) {
  rotator.set(Vector3.Z, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: libgdx/libgdx

/** Rotates along local X axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateX (float angle) {
  rotator.set(Vector3.X, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: libgdx/libgdx

/** Rotates along local Z axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateZ (float angle) {
  rotator.set(Vector3.Z, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: libgdx/libgdx

/** Rotates along local Y axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateY (float angle) {
  rotator.set(Vector3.Y, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: libgdx/libgdx

+ ParticleChannels.XOffset], qy = rotationChannel.data[offset + ParticleChannels.YOffset], qz = rotationChannel.data[offset
  + ParticleChannels.ZOffset], qw = rotationChannel.data[offset + ParticleChannels.WOffset];
TMP_Q.set(wx, wy, wz, 0).mul(qx, qy, qz, qw).mul(0.5f * controller.deltaTime).add(qx, qy, qz, qw).nor();
rotationChannel.data[offset + ParticleChannels.XOffset] = TMP_Q.x;
rotationChannel.data[offset + ParticleChannels.YOffset] = TMP_Q.y;

代码示例来源:origin: libgdx/libgdx

+ ParticleChannels.XOffset], qy = rotationChannel.data[offset + ParticleChannels.YOffset], qz = rotationChannel.data[offset
  + ParticleChannels.ZOffset], qw = rotationChannel.data[offset + ParticleChannels.WOffset];
TMP_Q.set(wx, wy, wz, 0).mul(qx, qy, qz, qw).mul(0.5f * controller.deltaTime).add(qx, qy, qz, qw).nor();
rotationChannel.data[offset + ParticleChannels.XOffset] = TMP_Q.x;
rotationChannel.data[offset + ParticleChannels.YOffset] = TMP_Q.y;

代码示例来源:origin: libgdx/libgdx

/** Spherical linearly interpolates multiple quaternions by the given weights and stores the result in this Quaternion. Will not
 * destroy the data previously inside the elements of q or w. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where the sum of w_i
 * is 1. Lists must be equal in length.
 * @param q List of quaternions
 * @param w List of weights
 * @return This quaternion for chaining */
public Quaternion slerp (Quaternion[] q, float[] w) {
  // Calculate exponents and multiply everything from left to right
  set(q[0]).exp(w[0]);
  for (int i = 1; i < q.length; i++)
    mul(tmp1.set(q[i]).exp(w[i]));
  nor();
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Spherical linearly interpolates multiple quaternions and stores the result in this Quaternion. Will not destroy the data
 * previously inside the elements of q. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where w_i=1/n.
 * @param q List of quaternions
 * @return This quaternion for chaining */
public Quaternion slerp (Quaternion[] q) {
  // Calculate exponents and multiply everything from left to right
  final float w = 1.0f / q.length;
  set(q[0]).exp(w);
  for (int i = 1; i < q.length; i++)
    mul(tmp1.set(q[i]).exp(w));
  nor();
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Spherical linearly interpolates multiple quaternions and stores the result in this Quaternion. Will not destroy the data
 * previously inside the elements of q. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where w_i=1/n.
 * @param q List of quaternions
 * @return This quaternion for chaining */
public Quaternion slerp (Quaternion[] q) {
  // Calculate exponents and multiply everything from left to right
  final float w = 1.0f / q.length;
  set(q[0]).exp(w);
  for (int i = 1; i < q.length; i++)
    mul(tmp1.set(q[i]).exp(w));
  nor();
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Spherical linearly interpolates multiple quaternions by the given weights and stores the result in this Quaternion. Will not
 * destroy the data previously inside the elements of q or w. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where the sum of w_i
 * is 1. Lists must be equal in length.
 * @param q List of quaternions
 * @param w List of weights
 * @return This quaternion for chaining */
public Quaternion slerp (Quaternion[] q, float[] w) {
  // Calculate exponents and multiply everything from left to right
  set(q[0]).exp(w[0]);
  for (int i = 1; i < q.length; i++)
    mul(tmp1.set(q[i]).exp(w[i]));
  nor();
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Averages the given transforms and stores the result in this matrix. Translations and scales are lerped while rotations are
 * slerped. Does not destroy the data contained in t.
 * @param t List of transforms
 * @return This matrix for chaining */
public Matrix4 avg (Matrix4[] t) {
  final float w = 1.0f / t.length;
  tmpVec.set(t[0].getScale(tmpUp).scl(w));
  quat.set(t[0].getRotation(quat2).exp(w));
  tmpForward.set(t[0].getTranslation(tmpUp).scl(w));
  for (int i = 1; i < t.length; i++) {
    tmpVec.add(t[i].getScale(tmpUp).scl(w));
    quat.mul(t[i].getRotation(quat2).exp(w));
    tmpForward.add(t[i].getTranslation(tmpUp).scl(w));
  }
  quat.nor();
  setToScaling(tmpVec);
  rotate(quat);
  setTranslation(tmpForward);
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Averages the given transforms and stores the result in this matrix. Translations and scales are lerped while rotations are
 * slerped. Does not destroy the data contained in t.
 * @param t List of transforms
 * @return This matrix for chaining */
public Matrix4 avg (Matrix4[] t) {
  final float w = 1.0f / t.length;
  tmpVec.set(t[0].getScale(tmpUp).scl(w));
  quat.set(t[0].getRotation(quat2).exp(w));
  tmpForward.set(t[0].getTranslation(tmpUp).scl(w));
  for (int i = 1; i < t.length; i++) {
    tmpVec.add(t[i].getScale(tmpUp).scl(w));
    quat.mul(t[i].getRotation(quat2).exp(w));
    tmpForward.add(t[i].getTranslation(tmpUp).scl(w));
  }
  quat.nor();
  setToScaling(tmpVec);
  rotate(quat);
  setTranslation(tmpForward);
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Averages the given transforms with the given weights and stores the result in this matrix. Translations and scales are
 * lerped while rotations are slerped. Does not destroy the data contained in t or w; Sum of w_i must be equal to 1, or
 * unexpected results will occur.
 * @param t List of transforms
 * @param w List of weights
 * @return This matrix for chaining */
public Matrix4 avg (Matrix4[] t, float[] w) {
  tmpVec.set(t[0].getScale(tmpUp).scl(w[0]));
  quat.set(t[0].getRotation(quat2).exp(w[0]));
  tmpForward.set(t[0].getTranslation(tmpUp).scl(w[0]));
  for (int i = 1; i < t.length; i++) {
    tmpVec.add(t[i].getScale(tmpUp).scl(w[i]));
    quat.mul(t[i].getRotation(quat2).exp(w[i]));
    tmpForward.add(t[i].getTranslation(tmpUp).scl(w[i]));
  }
  quat.nor();
  setToScaling(tmpVec);
  rotate(quat);
  setTranslation(tmpForward);
  return this;
}

代码示例来源:origin: libgdx/libgdx

/** Averages the given transforms with the given weights and stores the result in this matrix. Translations and scales are
 * lerped while rotations are slerped. Does not destroy the data contained in t or w; Sum of w_i must be equal to 1, or
 * unexpected results will occur.
 * @param t List of transforms
 * @param w List of weights
 * @return This matrix for chaining */
public Matrix4 avg (Matrix4[] t, float[] w) {
  tmpVec.set(t[0].getScale(tmpUp).scl(w[0]));
  quat.set(t[0].getRotation(quat2).exp(w[0]));
  tmpForward.set(t[0].getTranslation(tmpUp).scl(w[0]));
  for (int i = 1; i < t.length; i++) {
    tmpVec.add(t[i].getScale(tmpUp).scl(w[i]));
    quat.mul(t[i].getRotation(quat2).exp(w[i]));
    tmpForward.add(t[i].getTranslation(tmpUp).scl(w[i]));
  }
  quat.nor();
  setToScaling(tmpVec);
  rotate(quat);
  setTranslation(tmpForward);
  return this;
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

/** Rotates along local Z axis by the specified angle
 * 
 * @param angle Angle in degrees to rotate by */
public void rotateZ (float angle) {
  rotator.set(Vector3.Z, angle);
  rotation.mul(rotator);
  updated = false;
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

/** Spherical linearly interpolates multiple quaternions and stores the result in this Quaternion. Will not destroy the data
 * previously inside the elements of q. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where w_i=1/n.
 * @param q List of quaternions
 * @return This quaternion for chaining */
public Quaternion slerp (Quaternion[] q) {
  // Calculate exponents and multiply everything from left to right
  final float w = 1.0f / q.length;
  set(q[0]).exp(w);
  for (int i = 1; i < q.length; i++)
    mul(tmp1.set(q[i]).exp(w));
  nor();
  return this;
}

相关文章