Hi Luc,
> I'd like to compute the intersection between a ray and an ellipsoid
> model object. I think that the best idea will be to compute the 4x4
> transformation that distorts a sphere into the ellipsoid model.
> However, I wonder how can I extract this matrix from the ellipsoid
> model ?
I've been offline for a couple of months with a home renovation project,
and as I was scanning through the mail list (3000+) I saw you had not
received an answer yet.
I've used distorted sphere method myself, and it is fairly simple. If
you already have a raySphereIntersect routine, you can wrap it in
something like the following:
bool rayEarthIntersect(osg::Vec3d origin, osg::Vec3d ray, osg::Vec3d&
intersection)
{
double p = ellipsoid.getRadiusPolar();
double e = getRadiusEquator();
// Create a matrix composed the 3 axis multiplied by respective
// radii. OSG is z-axis up, thus multply z-axis with polar radius
// and x & y axis with equator radius
osg::Matrixd ellipsoid_scale(e, 0, 0, 0,
0, e, 0, 0,
0, 0, p, 0,
0, 0, 0, 1);
osg::Matrixd invert_scale(osg::Matrixd::inverse(ellipsoid_scale));
// Apply inverse ellipsoid scale to transform origin and ray
origin = invert_scale.postMult(origin);
ray = invert_scale.postMult(ray);
// Use the transformed ray vector and origin point to do
// intersection test with a sphere with center at 0,0,0 and radius=1
osg::Vec3d intersection;
if(raySphereIntersect(origin, ray, osg::Vec3d(0,0,0), 1.0,
interection))
{
// Transform intersection point to original ellipsoid
intersection = ellipsoid_scale.postMult(intersection);
return true;
}
else
return false;
}
Best regards,
John
Luc Claustres wrote:
Hi,
I'd like to compute the intersection between a ray and an ellipsoid model
object. I think that the best idea will be to compute the 4x4 transformation
that distorts a sphere into the ellipsoid model. However, I wonder how can I
extract this matrix from the ellipsoid model ?
Any other (simple) idea is also welcome...
Thank you!
Cheers,
Luc
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=24210#24210
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org