Notifications
Clear all

[Closed] how to caculate a line's reflected ray

the reflection plane maybe is a line ,an arc or some other 2D geometric drawing

3 Replies

Not sure if I understand the question; Is this what you’re trying to do? You have a shape, an incoming vector that hits the shape at some arbitrary point, and you want to calculate the reflection vector at that point? Please elaborate.

Martijn

yes , just as you said , is there some methods to realize it ?

When your shapes are actually curved, it’s not an easy task to find the intersection point, for straight lines it’s a lot simpler. I don’t have the time to write that code for you right now, but this should get you started.

Calculating the reflection vector is pretty easy, here’s an example:

-- Get tangent vector halfway Line01
pathVec = tangentCurve3D $Line01 1 .5

-- Get vector from Line02
rayVec = normalize ((getKnotPoint $Line02 1 2) - (getKnotPoint $Line02 1 1))

-- Calculate reflection vector
reflectionVec = 2 * (dot -rayVec pathVec) * pathVec + rayVec

This code assumes you have 2 lines in your scene, one named Line01 (the “mirror” shape) and one named Line02 (the “ray” shape)…

Hope this helps,
Martijn