Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7954 > unrolled thread

Signed area demo using hatching

Started byChris Young <cy56@comcast.net>
First post2012-01-17 11:02 +0000
Last post2012-01-17 11:02 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Signed area demo using hatching Chris Young <cy56@comcast.net> - 2012-01-17 11:02 +0000

#7954 — Signed area demo using hatching

FromChris Young <cy56@comcast.net>
Date2012-01-17 11:02 +0000
SubjectSigned area demo using hatching
Message-ID<jf3kfu$qa7$1@smc.vnet.net>
Finally got the hatching demo working. Thank you, John, for pointing 
out that the problem was that only one Locator control specification is 
allowed in a Manipulate, although you can actually have as many 
locators as you want. Unfortunately, that means you have to divide up 
the list of locators, instead of just creating locators with the names 
you want.

On Jan 16, 2012, at 6:04 PM, John Fultz wrote:
Manipulate only supports one Locator control at a time, but your Manipulate has
two.  You need to reformulate it so that all four Locator points are in 
a single
Locator control.

The reason for this is because Manipulate doesn't actually use Locator, but
LocatorPane, and overlapping LocatorPanes makes no sense.  In an ideal world,
Manipulate might attempt to combine the controls into a single LocatorPane, but
there would still be limitations (for example, adding and deleting locators
would make much less sense).

Here's a demo of signed area using hatchlines. Wherever the red and 
green hatchlines cancel out, the net area is zero. This illustrates the 
"Surveyor's formula" for area, 
http://en.wikipedia.org/wiki/Surveyor%27s_formula#Area_and_centroid . 

Should rewrite the routine with options and defaults, but it's pretty 
fast, especially with PlotPoints at 30. 

http://home.comcast.net/~cy56/Mma/SignedArea.nb
http://home.comcast.net/~cy56/Mma/SignedAreaPic1.png
http://home.comcast.net/~cy56/Mma/SignedAreaPic2.png
http://home.comcast.net/~cy56/Mma/SignedAreaPic3.png

\[HorizontalLine]TriHatch[A_, B_, C_, mesh_, light_, plotPts_, 
  opts___] :=
 Module[
  {
   orient,           (* orientation of the triangles *)
   
   interior,      (* inequalities for interior of triangle *)
   
   Q                          (* 
   projection of first vertex onto opposite side *)
   },
  orient = Sign[Det[{B - A, C - A}]];
  
  interior[P_] :=
   And @@ (If[orient > 0, # > 0, # < 0] & /@ 
      {Det[{B - A, P - A}],  Det[{C - B, P - B}], 
       Det[{A - C, P - C}] });
  
  Q = Projection[A - B, C - B] + B;
  
  RegionPlot[
   interior[{x, y}],  {x, -2, 2}, {y, -2, 2},
   
   PlotStyle -> Opacity[0],
   ColorFunction -> (White &),
   
   Mesh -> Round[
     mesh Max[Norm[C - B], Norm[Q - B], Norm[Q - C]],
     1
     ],
   
   MeshStyle -> Directive[
     Opacity[0.5],
     If[orient > 0, Lighter[Green, light], Lighter[Red, light]]
     ],
   
   MeshFunctions -> {{x, y} \[Function] Det[{Q - A, {x, y} - A}]},
   PlotPoints -> plotPts,
   BoundaryStyle -> None,
   Evaluate[opts]
   ]
  ]

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web