3
$\begingroup$

I would like to make a circle with radius 1 with axeses showed.

I would like to dynamically select a point on the circle, draw a line from that point to the center and draw the tangent line to that point.

Should I use a ParametricPlot[] in some way?

Is it possible to make that, dynamic moving the point with the mouse or a slider is needed?

$\endgroup$
5
$\begingroup$

This version is virtually identical to J.M.'s fine answer. It uses Manipulate rather than DynamicModule.

Update

Edited as per suggestion from Michael E2 to use TrackingFunction which eliminates the use of Dynamic entirely (neglecting the fact that the first argument of Manipulate is internally wrapped in a Dynamic).

A locator with the point initialized to lie on the circle at a 45 degree angle is used as the Manipulator control. Further the position of the point is constrained to lie on the circle using TrackingFunction.

Manipulate[

 Graphics[{
   {Blue, Circle[]},
   {Dashed, Line[{{0, 0}, pt}]},
   {Red, InfiniteLine[pt, Cross[pt]]}
   },
  Axes -> True,
  PlotRange -> 3/2
  ],

 {{pt, {1, 1}/Sqrt[2]}, Locator, 
  TrackingFunction -> ((pt = Normalize[#]) &)}
 ]

Mathematica graphics

$\endgroup$
  • 2
    $\begingroup$ If I was going to use Manipulate, I would take advantage of its features, like automatic construction of Locator controls and TrackingFunction: Manipulate[Graphics[{{Blue, Circle[]}, {Dashed, Line[{{0, 0}, pt}]}, {Red, InfiniteLine[pt, Cross[pt]]}}, Axes -> True, PlotRange -> 3/2], {{pt, {1, 1}/Sqrt[2]}, Locator, TrackingFunction -> ((pt = Normalize[#]) &)}] $\endgroup$ – Michael E2 May 11 '17 at 12:52
  • $\begingroup$ @MichaelE2 Good suggestion (I have been fairly ignorant of TrackingFunction). Modified answer as per your suggestion. $\endgroup$ – Jack LaVigne May 11 '17 at 13:06
  • $\begingroup$ @JackLaVigne Perfect, thank you. If I would like also to draw segment from the point to the axes, what should I add? $\endgroup$ – Ale1794 May 11 '17 at 20:50
  • 1
    $\begingroup$ @Ale1794 Look up Line and Part, e.g. pt[[1]] and pt[[2]]. $\endgroup$ – Michael E2 May 11 '17 at 22:26
  • $\begingroup$ @Ale1794 Add these lines to the list enclosed by Graphics. {RGBColor[0, 0.7, 0], Line[{{pt[[1]], 0}, pt}]}, {Magenta, Line[{{0, pt[[2]]}, pt}]}. $\endgroup$ – Jack LaVigne May 12 '17 at 13:51
6
$\begingroup$

Here's a simple version:

DynamicModule[{pt = {1, 1}/Sqrt[2]}, 
              LocatorPane[Dynamic[pt, (pt = Normalize[#]) &], 
                          Graphics[{{Blue, Circle[]},
                                    {Dashed, Line[{{0, 0}, Dynamic[pt]}]},
                                    {Red, InfiniteLine[Dynamic[pt], Dynamic[Cross[pt]]]}},
                                   Axes -> True, PlotRange -> 3/2]]]

circle and tangent

I'll leave the fancy styling up to you.

$\endgroup$

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.