2
$\begingroup$

I want to draw a Y-shaped branch in Mathematica. I am trying to draw a line of length L. In step II, I want to translate to the ending point of the line. Then I want to rotate at an angle of 45 deg to the right and draw a line of length L*0.66. Then translate back to the ending point of the first line and draw a line to the left by rotating left at an angle of 45deg. I have tried four several hours but got no success. Below is the code which I have tried:

    L = 100;
    Graphics[
        line = Line[{{0, 0}, {0, -L}}];
        Translate[line, {L/2, L}],
        line = Line[{{0, 0}, {0, - L*0.66}}];
        Rotate[line, -30 Degree]
    ]   
$\endgroup$
  • $\begingroup$ The variable p is undefined. And after Graphics, you want the graphics elements to be enclosed in a List or {..} $\endgroup$ – Michael E2 Sep 2 '18 at 0:48
  • $\begingroup$ Graphics[{Line[{{{0, 0}, {0, -1}}, {{0, 0}, {1/2, 1}}, {{0, 0}, {-1/2, 1}}}]}]? $\endgroup$ – Michael E2 Sep 2 '18 at 1:05
2
$\begingroup$

You can use Rotate, Translate and Scale:

line = Line[{{0, 0}, {0, -L}}];
Graphics[{line, 
 Scale[#, 2/3, {0, 0}] & /@ 
   (Rotate[Translate[line, {0, L}], # Degree, {0, 0}] & /@ {-30, 30})}]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you so much. $\endgroup$ – BiSarfraz Sep 2 '18 at 1:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.