Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple programming techniques / tricks in Mathematica for making graphics for the math book? [closed]

I tried to use it. And it's really nice for some Plots, but when its about making for example a triangle I found it quite complicated. I figured out how to draw a triangle but how to add that angle marks, those curved lines?

And since I'm beginner into this job, of writing a book, can anyone recommend me which is the best way to accomplish good looking graphics, for example as in the picture below. Which programs are best to use. enter image description here

Thanks for any suggestions and recommendations.

like image 470
balboa Avatar asked Jan 05 '12 19:01

balboa


People also ask

Is Mathematica difficult?

Mathematica is much prettier than others. Pros: The ability to solve symbolic mathematical equations is better compared to any other software. The graphing and data analysis capabilities are up to par. Not very difficult to learn.

What can Mathematica do you in the field of mathematics?

Mathematica allows for automation in algorithmic computation, interactive manipulation, and dynamic presentation, as well as allowing for interacting with the world of data.

Why we need Mathematica?

Mathematica is unique among technical computing platforms because it includes a vast collection of carefully curated data of all kinds, continuously updated and expanded. Access standard data without any overhead, including Wolfram|Alpha, the world's largest collection of computable data.

Should I get Mathematica?

Mathematica is a wonderful environment to do science - not only math - and you will find it useful in many ways in the years to come. Consider it as an investment. Wolfram did a very good thing (marketing-wise it's more a pusher's move... :-) ) with the Home edition, so that it is now affordable to almost everyone.


2 Answers

Here is a simple/basic way to do the first one:

Graphics[{

 (* The dashed circle segment *)
 {
  Dashing[{.04, .01}], 
  Darker[Orange], 
  AbsoluteThickness[2], 
  Circle[{0, 0}, 1, {1, 2 \[Pi]}]
 },

 (* The solid circle segment *)
 {
  Orange, 
  AbsoluteThickness[2], 
  Circle[{0, 0}, 1, {0, 1}]
 },

 (* The radial lines and the small circle segment *)
 Line[{{0, 0}, {1, 0}}],
 Line[{{0, 0}, {Cos[1], Sin[1]}}],
 Circle[{0, 0}, .2, {0, 1}],

 (* Various text labels *)
 {
  Text[Style["\[Theta]", 24], .3 {Cos[.5], Sin[.5]}], 
  Text[Style["s", 24], 1.1 {Cos[.5], Sin[.5]}], 
  Text[Style["r", 24], {.5, -.1}]
 }
}]

Mathematica graphics

The following is the exact same thing, but wrapped in Manipulate and parameterized on the angle alpha:

Manipulate[
 Graphics[{
  {Dashing[{.04, .01}], Darker[Orange], AbsoluteThickness[2], 
  Circle[{0, 0}, 1, {\[Alpha], 2 \[Pi]}]},
  {Orange, AbsoluteThickness[2], Circle[{0, 0}, 1, {0, \[Alpha]}]},
  Line[{{0, 0}, {1, 0}}],
  Line[{{0, 0}, {Cos[\[Alpha]], Sin[\[Alpha]]}}],
  Circle[{0, 0}, .2, {0, \[Alpha]}],
  {Text[Style["\[Theta]", 
  24], .3 {Cos[\[Alpha]/2], Sin[\[Alpha]/2]}], 
  Text[Style["s", 24], 1.1 {Cos[\[Alpha]/2], Sin[\[Alpha]/2]}], 
  Text[Style["r", 24], {.5, -.1}]}
 }],
{{\[Alpha], 1}, 0, 2 \[Pi]}]

If you move the slider, the content will change accordingly:

Mathematica graphics

like image 188
Arnoud Buzing Avatar answered Oct 19 '22 19:10

Arnoud Buzing


Edit You can get inspiration from the Demonstrations project too. These are the triangle-related demonstrations. After taking a quick look, I think you should see the geometry-related demonstrations by Jay Warendorff. He has made a lot of these, and they use a structured set of geometry-related functions that you most likely can reuse.


Here's an angleArc function to get you started. This is just a small example of a helper function you could use, there's a lot of room for improvement.

angleArc[Polygon[vertices_List, ___], r_, i_] :=
 Module[{a, b, c, phi1, phi2},
  {a, b, c} = Take[RotateLeft[vertices, i-2], 3];
  {phi1, phi2} = Sort@N[{ArcTan @@ (a - b), ArcTan @@ (c - b)}];
  If[phi2 - phi1 > Pi, phi1 += 2 Pi];
  Circle[b, r, {phi2, phi1}]
 ]

poly = Polygon[{{0, 0}, {1, 2}, {2, 1}}];

Graphics[{EdgeForm[Thick], FaceForm[None], poly, 
  Table[angleArc[poly, .2, i], {i, Length[poly[[1]]]}]}]

Mathematica graphics

Manipulate[
 With[{poly = Polygon[{a, b, c}]},
  Graphics[
   {EdgeForm[Thick], FaceForm[None], poly, 
    Table[angleArc[poly, .2, i], {i, Length[poly[[1]]]}]},
   PlotRange -> 2 {{-1, 1}, {-1, 1}}, Frame -> True
   ]
  ],
 {{a, {0, 0}}, Locator}, {{b, {1, 0}}, Locator}, {{c, {0, 1}}, Locator}
 ]

Mathematica graphics

like image 14
Szabolcs Avatar answered Oct 19 '22 20:10

Szabolcs