RE: Graphics

• To: mathgroup at smc.vnet.net
• Subject: [mg34804] RE: [mg34800] Graphics
• From: "Annetts, Dave (E&M, North Ryde)" <David.Annetts at csiro.au>
• Date: Sat, 8 Jun 2002 05:21:10 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```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]}]
Show[Graphics[Line[vrts]]];

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

should cure things ....

Regards,

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

```

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