# [collective thread] arbitrary WLDC example — Questions?

Posted 4 months ago
524 Views
|
3 Replies
|
4 Total Likes
|
 Most example codes in the WLDC are so well-chosen and instructive/didactic/educational/helpful that the one-liner is not accompanied by sufficient but concise or "none" explanation. And only on very rare occasions would we stumble over example code which we really "don't get" (the point/purpose/intention/reason d'etre/function) - basically these are examples which should have gotten improved code or better/more explanations in order to make the reader understand.Maybe it is a good idea to question some arbitrary given example which you have come across while studying the WLDC? In a collective effort we could point out questionable examples (and comment on the post with the according Reply-button) and possibly suggest improvements to code or text. This thread is not primarily about reporting typos/errors/bugs but they could be part of the problem why we don't get the example, sometimes.For easy reference, let's include the documentation reference URL of the function and also indicate the examples subsection where to find the referred example. I have bookmarked & memorized this thread URL for convenient access/future additions under:https://tinyurl.com/wldcexample
3 Replies
Sort By:
Posted 4 months ago
 Let me start with this example from the WLDC:Dynamic[ ] > Applications > 1st example: Constrain the coordinates of a point to lie on a circle: DynamicModule[{p = {0, 1}}, Graphics[{ Dashed , Circle[] , PointSize[0.1] , Point[ Dynamic[p, (p = Normalize[#]) &] ] }, PlotRange -> 1.2, Axes -> True, ImageSize -> Tiny] ]  Comments: The text is clear, it makes the intention clear. Or at least I think so. Well, I am understanding: We want to constrain a (given? any? dynamically given? interactively given?) point to lie on the circle (radius 1, center at {0,0}). Where can we observe the dynamics? Or where is the interactivity? The initial point is given with {0,1}. This point already lies on the unit circle! And the point cannot be moved or anything with my mouse. So i really don't see any dynamics or interactivity here. To constrain a point to lie on a circle with some dynamics, maybe the function Locator[ ] should have been used in the code? Maybe this example is not to demo interactivity with the mouse or any kind of dynamics? However, edit the code and use the point p = {-1, 1} in the module initialization. You will see that the point is drawn outside the circle, i.e. neither the function Dynamic[ ] nor Normalize[ ] do their job. Seems like. At this point it is impossible for me to suggest an improved code and/or text which makes this example (input and output) clearer to the reader, because i clearly seem to be missing something. What am i missing here?
Posted 4 months ago
 Double click on the output to switch to editing/drawing mode and drag the point around.Yes, that is not obvious.
Posted 4 months ago
 Hello Kuba, thanks for the pointer. Yes, now i can see what is happening there, the dynamics, the functionality of the code. Wow.Many subtleties and implications regarding the Dynamic[ ] command are still half a mystery to me but i'll just have to re-read the respective documentation over and over again until it all falls into place, i hope ;-) .
Community posts can be styled and formatted using the Markdown syntax.