Jump to content
  • Advertisement
Sign in to follow this  
lilbobbel

Bounding Box for a disc?

This topic is 3674 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

Hey! I have following problem. I have a Disc, represented by position, radius and normal. Now i want to make a Bounding Box for of it. The easiest way i imagined was to grap some points on the border of the disc and extend an empty bounding box with them. But now, how do i get these points? Deciding wether a given point is in the plane is quite easy, but to get a point from a given plane...i don't have a idea.

Share this post


Link to post
Share on other sites
Advertisement
I have coded a method for generating a coordinate system out of a single normal after PBRT. Here is the whole sourcefile.

The function goes like


void computeCoordinateSystem (Vector3d &v1, Vector3d &v2, Vector3d &v3) const {
v1 = computeNormal();
// from PBRT
if (fabs (v1.m[0]) > fabs (v1.m[1])) {
real ilen = 1.0 / sqrt (v1.m[0]*v1.m[0] + v1.m[2]*v1.m[2]);
v2 = Vector3d (-v1.m[2] * ilen, 0.0, v1.m[0] * ilen);
} else {
real ilen = 1.0 / sqrt (v1.m[1]*v1.m[1] + v1.m[2]*v1.m[2]);
v2 = Vector3d (0.0, v1.m[2] * ilen, -v1.m[1] * ilen);
}
v3 = v1.computeCross (v2);
}




Now you could take your plane's normal, build an orthonormal basis with the above function, and e.g. random-sample points a disc in 2d and then transform them.

There's probably a better solution, but right now I have a day of regex-work behind me (kinda like 500 chars long ... so my brain is a bit, ..., like pudding), at least this should give a solution to your generate-point-on-disc problem. Maybe generate n=circumference*f points on the radius gives a satisfying solution for now.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!