0
\$\begingroup\$

I'm working on a collision system for a 2.5D game, and I'm stuck on the sphereoids. As long as scaling x=y=z, and it doesn't rotate, I can just use an r^2 check, but I'm trying to figure out a way to handle TOI solving when that is not the case.

What I realized is that if i generate an n-gon it will roll properly (i.e. no noticeable bumping from corners) so long as the collision mesh itself doesn't rotate, just sort of skews...

Anways, so I have a unit sphere at the origin, and a 4x4 transform matrix. And I want to find the lineloop that outlines it in an orthogonal projection.

And I've been trying to figure out how to write the sort of 2D X/Y projection in terms of the matrix transformed sphere for a while, and i can't figure it out. Partly this is because I don't understand the vector definition of a sphere, e.g. what a positive definite matrix is and if a rotation matrix qualifies...

This is about as far as i got:

$$ cos(\alpha) r = x m_0 + y m_1 + z m_2 $$ $$ sin(\alpha) r = x m_4 + y m_5 + z m_6 $$

But I'm pretty sure that's not solvable because it has 3 unknown variables in 2 equations, and there's nothing to constrain it to find a maximal value for r.

How can I do this and am I on the right track?

Edit:

so far figured out that for any 3D elipsoid there will be some 2D cross section which contains the maximal elipse.

Let this plane be defined as: $$\begin{bmatrix}x' \\ y' \\ z'\end{bmatrix} = \begin{bmatrix}ax & ay & az \\ bx & by & bz \end{bmatrix} \begin{bmatrix}x \\ y \end{bmatrix} $$

From there I can get the previous XYZ from xy coordinates, and multiply the matrices so that i get a single 2D rotation matrix:

$$ A = \begin{bmatrix} a & b \\ c & d \end{bmatrix} = \begin{bmatrix}ax & ay & az \\ bx & by & bz \end{bmatrix} \begin{bmatrix} m0 & m4 \\ m1 & m5 \\ m2 & m6 \end{bmatrix} $$

So I can find the point p i want:

$$ p = \dfrac{p}{|A^T * P|}$$

But i would still need to find said plane which i'm unsure how to do...

\$\endgroup\$

Your Answer

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

Browse other questions tagged or ask your own question.