rotateBy method

Sp3dFragment rotateBy(
  1. Sp3dV3D center,
  2. Sp3dObj parent,
  3. Sp3dV3D norAxis,
  4. double radian,
)

(en)Rotates all vectors of this fragment based on the specified axis. This method allows you to rotate this fragment around any point.

(ja)このフラグメントの全てのベクトルを指定した軸をベースに回転させます。 このメソッドを用いると、任意の点を中心としてこのフラグメントを回転できます。

  • center : center of rotation.
  • parent : parent obj.
  • norAxis : normalized rotate axis vector.
  • radian : radian = degree * pi / 180.

Implementation

Sp3dFragment rotateBy(
    Sp3dV3D center, Sp3dObj parent, Sp3dV3D norAxis, double radian) {
  final List<Sp3dV3D> fragmentVertices = [];
  for (Sp3dFace i in faces) {
    fragmentVertices.addAll(i.getVertices(parent));
  }
  final Sp3dV3D diff = Sp3dV3D(0, 0, 0) - center;
  _moveForRotateInPlace(fragmentVertices, diff);
  _rotateForRotateInPlace(fragmentVertices, norAxis, radian);
  _moveForRotateInPlace(fragmentVertices, diff * -1);
  return this;
}