help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help drawing a polygon using drawPolygon


From: Nicholas Jankowski
Subject: Re: help drawing a polygon using drawPolygon
Date: Tue, 21 Feb 2017 09:49:36 -0500

On Tue, Feb 21, 2017 at 7:47 AM, Anthony Andriano
<address@hidden> wrote:
> Hello,
>
> I've been looking at the documentation for a while and I can't figure out
> what I'm doing wrong. There doesn't seem to be an example to help guide a
> beginner in this process and the terms aren't exactly clear.

It seems there could be some improvements to the documentation here to
make things a bit more clear. It appears most of the description to
help you answer those questions is hiding in the
"See also: polygons2d"

so

>> help polygons2d

or simply

>> polygons2d

will give you the help text describing a good part of the required
usage info for polyline and polygon functions in this package.

in short:

(note your points are only a line, with all y = -2. I've change the
2nd point to [0,2] to make a triangle)


COORD = [-1, -2; 0, 2; 1, -2];
drawPolygon(COORD);


also:

close all;
PX = [-1 0 1];
PY = [-2 2 -2];
drawPolygon(PX,PY);

gives me the points [1 -2], [2 2], and [3 -2].  not sure why. but
making the PX and PY column vectors works:

close all;
PX = [-1 0 1]';
PY = [-2 2 -2]';
drawPolygon(PX,PY);


For the last one, the polygons2d text indicates that multiple polygons
can be included in a single COORD array using a [NaN, NaN] line as the
separator, but the text for drawPolygon(POLYS) indicates that POLYS
should be individual polygon coordinate sets in a cell array.

Trying:

COORD = [-1, -2; 0, 2; 1, -2; NaN, NaN; 5 0; 6 1; 7 0;];
drawPolygon(COORD);

gives me two triangles as expected.

close all;
POLYS = {[-1, -2; 0, 2; 1, -2], [5, 0;6, 1;7, 0]};
drawPolygon(POLYS);

Produces the same output.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]