0
\$\begingroup\$

The object is a capsule. I have the position of the object vector3, and the orientation of the object, a quaternion. I want to construct a line which goes through the middle of the capsule with the two endpoints of the line being the top and bottom.

The capsule can be rotated in all 3 dimensions.

\$\endgroup\$
0
\$\begingroup\$

Assuming your capsule is aligned along the y axis, it could look something like this:

top = centerPosition + orientation * (new Vector3(0, halfHeight, 0));
bottom = centerPosition + orientation * (new Vector3(0, -halfHeight, 0));

(Here I'm assuming quaternion * vector is evaluated as \$q v q^{-1}\$, rotating the vector by the quaternion)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.