Jerry
Jerry

Reputation: 29

Direction of angle after reflection

Say if I had a triangle and I was to draw a line towards one of the sides of the triangle, how would I create the reflected line of when that line hits the side of the triangle in Maple. I just drew this quickly in paints (and so its not accurately). Is there a way to do this in maple. Thanks I currently have,

with(plots):
with(plottools):

a:=polygon([[0,0],[2,0],[1,2]]):
b:=polygon([[2,0],[4,0],[3,2]]):
e:=line([2.5,2],[2.5,1]):
f:=line([2.5,1],[1.72,0.484]):

display(a,b,e,f);

Upvotes: 0

Views: 89

Answers (1)

MBo
MBo

Reputation: 80187

Let's starting direction is vector Dir (dir.x, dir.y), and side of reflection has unit normal N (n.x, n.y)

After reflection tangential component of vector is inverted and normal component remains the same. We can use equations below to calculate new direction:

dot = dir.x * n.x + dir.y * n.y

//after reflection
newdir.x = dir.x - 2 * dot * n.x
newdir.y = dir.y - 2 * dot * n.y

Apply such transformations to get a sequence of reflections from right and left triangle sides (using corresponding normals)

Upvotes: 1

Related Questions