MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Signed area demo using hatching

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, . 

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

\[HorizontalLine]TriHatch[A_, B_, C_, mesh_, light_, plotPts_, 
  opts___] :=
   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;
   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]],
   MeshStyle -> Directive[
     If[orient > 0, Lighter[Green, light], Lighter[Red, light]]
   MeshFunctions -> {{x, y} \[Function] Det[{Q - A, {x, y} - A}]},
   PlotPoints -> plotPts,
   BoundaryStyle -> None,

  • Prev by Date: Re: Question about DeleteCases to remove list elements based on first character
  • Next by Date: Re: Locator points not working in Manipulate calling RegionPlot, etc.
  • Previous by thread: Re: determining coefficients of a polynomial
  • Next by thread: For best performance Graphics Card Quadro 600 or geforce GTX 560 ?