Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Vector coordinates help
Lee_Hesketh
Member, Developers Posts: 148 ✭✭✭
Hello all. My mortise and tenon script is still a WIP and I have ran into yet another problem. I am using the corner of a rectangle as the reference point for an skRectangle() function. Suppose the coordinates of the corner are (-50, 50)*mm in the x-z plane, and I want to put a point that is 10mm across and 5mm down, I have a problem. This is because if I just say (-50,50) + (10,-5) using this corner, the point ends up here:
However, if I use the other corner with coordinates (50,50)*mm, I can't just do (50,50) + (10,-5) because the point ends up here:
How could I set this up such that it doesn't matter which corner is selected without using lots of if statements?
Thanks
Lee Hesketh
However, if I use the other corner with coordinates (50,50)*mm, I can't just do (50,50) + (10,-5) because the point ends up here:
How could I set this up such that it doesn't matter which corner is selected without using lots of if statements?
Thanks
Lee Hesketh
There are 10 types of people in the world. Those who know binary, those who don't and those who didn't expect base 3!
Tagged:
0
Best Answer
-
mahir Member, Developers Posts: 1,307 ✭✭✭✭✭You could change the sign of your offset based on the the difference between the selected point and and center of the rectangle in question (Pc). You could use either evBox3d or evApproximateCentroid.
if(Xc-X0<0) deltaX *= -1
if(Yc-Y0<0) deltaY *= -1
P1 = P0 + (deltaX, deltaY)
Or, if you have vector data for the other corners, you could just substitute the average of those points for Pc. You just need to know which way is the body.5
Answers
if(Xc-X0<0) deltaX *= -1
if(Yc-Y0<0) deltaY *= -1
P1 = P0 + (deltaX, deltaY)
Or, if you have vector data for the other corners, you could just substitute the average of those points for Pc. You just need to know which way is the body.