Notifications
Clear all
[Closed] mirror point across vector?
Apr 30, 2016 1:12 pm
How can i calculate the mirrored position for a point? Keep in mind these are points I’m dealing with, NOT transforms. So the only information i have is positions.
You can see in the image I want to mirror the one point across the vector created by the other two points. This is in theory only 2D space, x,y.
Hope someone can help. Thanks
delete objects
a = point pos:[5,5,0] size:.5 wirecolor:yellow
b = point pos:[0,5,0] size:.5 wirecolor:red
c = point pos:[5,0,0] size:.5 wirecolor:red
3 Replies
Apr 30, 2016 1:12 pm
delete objects
a = point pos:[5,0,0] size:.5 wirecolor:yellow
p1 = point pos:[0,3,0] size:.5 wirecolor:red
p2 = point pos:[-4,2,0] size:.5 wirecolor:red
theAngle = acos(dot (normalize (a.pos - p1.pos)) (normalize (p2.pos - p1.pos)))
p3 = p1.pos + (normalize (p2.pos - p1.pos)) * (cos theangle)*(distance a.pos p1.pos)
p4 = p3 - (a.pos - p3)
point pos:p3 size:.5 wirecolor:green
point pos:p4 size:.5 wirecolor:orange
2 Replies
This is great thank you so much. Could you explain what is going on in the code please? I tested and it works perfect.
thanks
john
Just maths…
If you want to avoid cosinus functions and normalizing vectors (to be more accurate in decimals):
delete objects
a = point pos:[5,0,0] size:.5 wirecolor:yellow
p1 = point pos:[0,3,0] size:.5 wirecolor:red
p2 = point pos:[-4,2,0] size:.5 wirecolor:red
u = p2.pos - p1.pos
t = (dot u (a.pos - p1.pos)) / (dot u u)
p3 = p1.pos + t*u
p4 = 2 * p3 - a.pos
point pos:p3 size:.5 wirecolor:green
point pos:p4 size:.5 wirecolor:orange
Of course, you have to check (p2 != p1)