For all issues regarding the Forums use, please, refer to the Forum Rules.

### Our Solutions

Need professional assistance?
Consider our:

Need to speed up your development?
Have a look at our:

Need some functionality extending standard OCCT capabilities?
Check out our:

# Project a Vector on a Plane

Forums:

Hi Everybody,
In my Project I want to project a 3D vector on a previuos selected plane.
There is any class or function I can use?
Thanks for any suggestion.
Best Regards,

Similar to the code I use for projecting 2d mouse co-ordinates on to a plane (see the code in http://www.opencascade.org/org/forum/thread_2785/), the factory class IntAna_IntConicQuad will project any gp_Lin class onto a gp_Pln class - this was the method I was given in Matra training materials sometime in the last century. Hope this helps.

Pete

gp_Vec normal = plane.Direction().XYZ();
gp_Vec prj = normal ^ vec ^ normal;

First of all, thanks for your suggestion.
I'm sorry but I do not understend the line: "plane.Direction().XYX();"
Compiling this code, I had this error:
"'direction' : is not a member of 'gp_Pln'"
What can I do?
Thanks.

simple correction:
gp_Vec normal = pln.Axis().Direction().XYZ();

Bearloga

I hadn't noticed the ^ operator in the class 'til your post and I thought the poster's problem was extending the vector to the plane, not projecting the vector onto the plane. I'm trying to get the associativity and order of precedence of a ^ b ^ a right in my head now - any thoughts?

Pete

Thank you very much, the code works, but I have another question, if you can help me.
Now that I have the projected vector, I must set its Magnitude equal to my original vector.
There is a function that allow me to modify vactor's magnitude? I did not found anything useful in gp_Vec class.

Why the methods Multiply and Divide (operators *= and /=) do not satisfy you? :-(

You are right....Thank you very much.

You are right....i didn't think at this methods at all.....
One last thing, the first point of my vector, how can I find it? I'm thinking about it but if you can help you will make me a big big favor.
Thank you very much.