Creating a line without having to input their coordinates in maple

135 Views Asked by At

I have two lines and one angle, and I want to display the other line in Maple. How do I do this?

I want to add another line at a certain angle where this other line (in the image) and the line from the triangle meet. How do I do this other than calculating it manually. Can I create a continuous line other than using coordinates.

Image I want to replicate in maple

1

There are 1 best solutions below

2
On BEST ANSWER

As requested, here's a Maple function, reflect, that takes as inputs, an initial point $p$, a nonzero vector $v$, and a line $L$, all in $\mathbb{R}^2$, and returns the point where the ray $r$ from $p$, in the direction $v$, hits $L$, and a vector giving the direction of the reflection of $r$ off $L$.

Input format:

  • $p$ is expected to be in the form $[x0,y0]$, a list of two real numbers, representing a point $(x0,y0)$.$\\[4pt]$
  • $v$ is expected to be in the form $[a,b]$, a list two real numbers, not both zero, representing a nonzero direction vector $\langle{a,b}\rangle$ for the ray from $p$.$\\[4pt]$
  • $L$ is expected to be in the form $Ax+By=C$, where $x,y$ are unknowns, and $A,B,C$ are real constants, with $A,B$ not both zero.

Output format:

  • If the input ray $r$ does not hit $L$, the empty list is returned.$\\[4pt]$
  • Otherwise, the output is a ray $r_1=[p_1,v_1]$, where $p_1 = [x_1,y_1]$ represents the point where the ray $r$ hits $L$, and $v_1=[a_1,b_1]$ represents the direction vector of the reflection of $r$ off $L$.

Here's the code for reflect . . .

enter image description here

Next, a Maple function traj which gives the trajectory of an input beam as it bounces back and forth between the triangles $T_1$ and $T_2$, as specified in your setup.

Input format:

  • $x_0$ is expected to be a real number in the open interval $(1,3)$, representing the $x$-coordinate of an initial point $p_0=(x_0,2)$.$\\[4pt]$
  • $v_0$ is expected to be in the form $[a_0,b_0]$, a list two real numbers, not both zero, representing a nonzero direction vector $\langle{a,b}\rangle$ for the ray from $p_0$.

Notes:

  • The triangles $T_1$ and $T_2$ are hard-coded.

Output format:

  • The output is a list of points $[[x_0,y_0],...,[x_n,y_n]]$, representing the trajectory of the sequence of reflections, constrained to the closed region between the two triangles, and below or on the line $y=2$.

Notes:

  • The initial ray is expected to be such that it first hits the left boundary of $T_2$, in the constrained region.

Here's the code for traj . . .

enter image description here

Next, we have a Maple function show, which takes as input, the output from traj, and displays the two triangles, together with a graphical reprentation of the reflections corresponding to the specified trajectory.

Here's the code for show . . .

enter image description here

Finally, a sample run, using an initial point $({\large{\frac{5}{2}}},2)$, and an initial direction vector $\langle{0,-1}\rangle$ . . .

enter image description here