0
|
2420 Views
|
2 Replies
|
3 Total Likes
View groups...
Share

# Elementary Question about using Rules

Posted 10 years ago
 I'm a beginner in Mathematica; I have a question on a Mathematica homework set, that seems to me should be pretty simplistic, but I seem to be hitting a wall. My error must be completely obvious, but can someone please teach me the proper way of doing this? In the following example, change every Point to a Circle with radius 1/2, centered around the point, using a Rule application. The code give was Graphics[{PointSize[.02],Point[{9,5}],Point[{2,-5}],Point[{5,5}],Point[{3,6}],Point[{1,1}],Point[{5,-7}],Point[{-7,4}], Point[{6,-10}],Point[{-6,-2}],Point[{0,8}],Point[{1,4}],Line[{{1,4},{2,5}}],Point[{2,5}]}] I altered it by Graphics[{PointSize[.02],Point[{9,5}],Point[{2,-5}],Point[{5,5}],Point[{3,6}],Point[{1,1}],Point[{5,-7}], Point[{-7,4}],Point[{6,-10}],Point[{-6,-2}],Point[{0,8}],Point[{1,4}],Line[{{1,4},{2,5}}],Point[{2,5}] /.{a_Point->Circle[{a},.5] Of course, this leads the program into entering the entire Point{x,y} into the coordinate place in the circle. Help please?
2 Replies
Sort By:
Posted 10 years ago
 Dear Kacey,this should work: Graphics[{PointSize[.02], Point[{9, 5}], Point[{2, -5}], Point[{5, 5}], Point[{3, 6}], Point[{1, 1}]}] /. Point[{x_, y_}] -> Circle[{x, y}, 1/2] I only demonstrate it for few points. It is not the best way, because the leading PointSize will still be in the list, but it does work because PointSize will simply be ignored.If you want the PointSize directive to be deleted to have a clearer command Graphics[Drop[{PointSize[.5], Point[{9, 5}], Point[{2, -5}], Point[{5, 5}], Point[{3, 6}], Point[{1, 1}]} /. Point[{x_, y_}] -> Circle[{x, y}, 1/2], 1]] does the trick. The output should be identical.Cheers, M.
Posted 10 years ago
 Worked beautifully-thanks!