• Advertisement
Sign in to follow this  

Plane on polygon

This topic is 4307 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have the following: 1: a plane define by a normal + d 2: a radius 3: a centre point I need to create a polygon made from 4 vertices which lie on the given plane, and so that the edges touch the edge of a circle with the given radius centred on the centre point. Like this:

Share this post


Link to post
Share on other sites
Advertisement
Here's one way to do it:

1. Construct the quad in local space, e.g. in the xy plane, centered at the origin, with +z forward
2. Create an arbitrary orthonormal basis from the plane normal
3. Create an affine transform (e.g. using a 4x4 matrix) from the basis and the center point
4. Use it to transform the 4 vertices of the quad

The only non-trivial step is number 2, but it's fairly simple and can be done with a few cross products (ask if you need details). You might also describe what it is you're actually trying to do, because depending on what it is, the above may not be the best solution.

Share this post


Link to post
Share on other sites
Could you please describe how I would create this matrix? I'm assuming once I have it I can just matrix multiply the vertices with it, right?

Share this post


Link to post
Share on other sites
From my point of view, the easiest way is to directly create the orthonormal system based on the plane equation. Let's say N is the plane normal (assuming it's already normalized) ;

Zaxis = N
Xaxis = N x (1,0,0)
if (Xaxis squared length is too small) Xaxis = N x (0,1,0)
if (Xaxis squared length is too small) Xaxis = N x (0,0,1)
Yaxis = Zaxis x Xaxis

V1 = Plane Center + radius * (Xaxis + Yaxis)
V2 = Plane Center + radius * (Xaxis - Yaxis)
V3 = Plane Center - radius * (Xaxis + Yaxis)
V4 = Plane Center - radius * (Xaxis - Yaxis)

Share this post


Link to post
Share on other sites
That seems to work fine, however I don't know what you mean by "if x axis squared is too short" what defines too short? Do you mean that if its total length is not equal to 1?

Share this post


Link to post
Share on other sites
I have forgotten a line in my pseudo-code ;
Xaxis = N x (1,0,0) will result in a vector which is not normalized. You will have to normalize it and therefore perform a division by the norm of Xaxis. This is where things may go wrong if Xaxis norm is 0 or nearly 0.

If N is colinear with (1,0,0) the length of Xaxis will be 0.
To keep good precision, you should avoid the situations were you build your Xaxis from 2 colinear (or nearly colinear) vectors.

You have two solutions for this ;
- The one i described ; you just try with the base vector (1,0,0), (0,1,0) and (0,0,1) and as soon as you have found one which is not colinear with N, you use it.
- You can also decide that the vector you need is the one for which N as the smallest coordinates ; N = (0.1, 0, 0.9) => Xaxis = N x (0,1,0)

Hope it helps

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement