MathGroup Archive 2002

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

Search the Archive

RE: Graphics

Hi Shz Shz,

> I have a very simple question. Maybe it is too simple to ask 
> but i really need help.
> Does anyone know how to
> 1) draw a triangle
> 2) draw a square
> with mathematica" ?
> I try to draw them by loading the Graphics'Arrow' package but it seem
> to benothing come out.

You'll need to look at the graphics primitives section of the book --
Graphics`Arrow draws arrows.

For a triangle, you can try
	Show[Graphics[Polygon[{{0, 0}, {0, 1}, {1, 0}}]]];
	Show[Graphics[Line[{{0, 0}, {0, 1}, {1, 0}, {0, 0}}]]];
depending upon whether you want it filled or not.

Similar deal with your square ....

An alternate method is to load Geometry`Polytopes, whence
	vrts = Vertices[Square]
	vrts = Join[vrts, {First[vrts]}]

Depending upon your point of view, the square may be rotated.  In this case,
load Geometry`Rotations`, and 
	rvrts = Rotate2D[#, Pi/4] & /@ vrts;
	Show[Graphics[{{Red, Line[rvrts]}, {Line[vrts]}}]];

should cure things ....


  Dr. David Annetts             EM Modelling Analyst
  Tel: (+612) 9490 5416         CSIRO DEM, North Ryde
  Fax: (+612) 9490 5467         David.Annetts at
                 Include "usual_disclaimers"

  • Prev by Date: Re: Coupled Differential Equations
  • Next by Date: ReadList with mixed strings and numbers
  • Previous by thread: Graphics
  • Next by thread: Re: Graphics