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


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

Hatching triangle interior

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

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


Contents

  Hatching triangle interior Chris Young <cy56@comcast.net> - 2012-01-16 11:50 +0000

#7865 — Hatching triangle interior

FromChris Young <cy56@comcast.net>
Date2012-01-16 11:50 +0000
SubjectHatching triangle interior
Message-ID<jf12tf$5fv$1@smc.vnet.net>
If the number of plot points is kept down, this does a pretty fast 
hatching of the triangle interior. Green for positive orientation, red 
for negative.

I'm hoping this can be generalized to any convex polygon via permuting 
the indices for a list of points.

http://home.comcast.net/~cy56/TriHatch.nb
http://home.comcast.net/~cy56/TriHatchPic1.png
http://home.comcast.net/~cy56/TriHatchPic2.png

\[HorizontalLine]TriHatch[P1_, P2_, P3_, 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[{P2 - P1, P3 - P1}]];

  interior[P_] :=
   And @@ (If[orient > 0, # > 0, # < 0] & /@
      {Det[{P2 - P1, P - P1}],  Det[{P3 - P2, P - P2}],  Det[{P1 - P3, 
P - P3}] });

  Q = Projection[P1 - P2, P3 - P2] + P2;

  RegionPlot[
   interior[{x, y}],  {x, -2, 2}, {y, -2, 2},
   ColorFunction -> (White &),
   Mesh -> Round[mesh Norm[P3 - P2], 1],
   MeshStyle ->
    If[orient > 0, Lighter[Green, light], Lighter[Red, light]],
   MeshFunctions -> {{x, y} \[Function] Det[{Q - P1, {x, y} - P1}]},
   PlotPoints -> plotPts
   ]
  ]

Chris Young

[toc] | [standalone]


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


csiph-web