rotateInPlace method

Sp3dFragment rotateInPlace(
  1. Sp3dObj parent,
  2. Sp3dV3D norAxis,
  3. double radian
)

(en)Rotates all vectors of this fragment based on the specified axis. Unlike rotate, rotateInPlace will perform the rotation with this fragment's mean coordinate as the origin.

(ja)このフラグメントの全てのベクトルを指定した軸をベースに回転させます。 rotateとは異なり、rotateInPlace はこのフラグメントの平均座標を原点として 回転が実行されます。

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

Implementation

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