We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I have written these lines of code:
Vec3D target, camPosition, myPosition;
...
...
Plane fPlane = new Plane(target, camPosition);
float distToFPlane = fPlane.getDistanceToPoint(myPosition);
They work perfectly but I'd like to know how to do the same thing without using toxiclibs.
Can you tell me how to do the same calculations only with Processing objects (as PVector) ?
Answers
Just use PVector.dist(). in the code you posted you specified target, camPosition and myPosition. your plane is created with target and camPosition (I think you want new Plane(camPosition, target) as it is _Plane(Vec3D origin, ReadonlyVec3D norm) _). If you use Plane.getDistanceToPoint(), i think the only distance you can get is the distance between the plane origin and myPosition, which is just measuring the distance between to points. so just write:
Hello, it's not the same thing: you propose to calculte the distance between two vectors. I want to calculate the distance between a vector and a plane.
I tried this solution before and the results are not the same.
I need to create my own simplified Plane class and getDistanceToPoint function but I don't know exactly how to use camPosition in relation with target (in my example).
But you are right about the constructor, I'm trying to rewrite this one:
Plane(Vec3D origin, ReadonlyVec3D norm)
http://toxiclibs.org/docs/core/toxi/geom/Plane.html
Ah, I think now i understand. the toxi plane method measures in the direction of the normal. than it is simple trigonometry:
Thank you! I need to revise trigo indeed ;)
I have found a fastest method :
(double post)