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\$

1 Answer 1

1
\$\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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .