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

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

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

Samples & Tools

 

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

Adv. Components

Related pages

Project a Vector on a Plane

Gionata's picture
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,
Quadri Gionata

P Dolbey's picture

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

Bearloga's picture

gp_Vec vec; // your vector
gp_Pln pln; // your plane
gp_Vec normal = plane.Direction().XYZ();
gp_Vec prj = normal ^ vec ^ normal;

Gionata's picture

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.
Quadri Gionata

Bearloga's picture

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

P Dolbey's picture

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

Gionata's picture

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.
Stil thanks for your help.
Quadri Gionata

Bearloga's picture

> I did not found anything useful in gp_Vec class
Why the methods Multiply and Divide (operators *= and /=) do not satisfy you? :-(

Gionata's picture

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

Gionata's picture

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.

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.