help drawing a polygon using drawPolygon

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

help drawing a polygon using drawPolygon

Anthony Andriano
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.

I'm trying to draw a triangle with the coordinates (-1, -2), (0, -2), and (1, -2). The documentation for drawPolygon suggests it can take a list of coordinates or some type of array, but I can't find any examples or explanations for how the data should be entered and nothing I've tried has worked.

drawPolygon(COORD) - what does it mean to 'pack' coords into a single array? How does one accomplish this?

drawPolygon(PX, PY) - how do you specify the coordinates in different arrays? I tried passing in [-1 -2], [0 2], [1 -2] as well as [-1; -2], [0; 2], [1; -2] to no avail.

drawPolygon(POLYS) - I looked up cell arrays, but none of the notation I've tried has worked here.

My goal is to draw a triangle at the given coordinates and then draw it again on the same plot using a different color after applying a linear transformation to rotate it. Any help or guidance anyone can offer would be greatly appreciated.

Thanks,
Tony

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help drawing a polygon using drawPolygon

James Sherman
On Tue, Feb 21, 2017 at 7:47 AM, Anthony Andriano
<[hidden email]> 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.
>
> I'm trying to draw a triangle with the coordinates (-1, -2), (0, -2), and
> (1, -2). The documentation for drawPolygon suggests it can take a list of
> coordinates or some type of array, but I can't find any examples or
> explanations for how the data should be entered and nothing I've tried has
> worked.
>
> drawPolygon(COORD) - what does it mean to 'pack' coords into a single array?
> How does one accomplish this?
>
> drawPolygon(PX, PY) - how do you specify the coordinates in different
> arrays? I tried passing in [-1 -2], [0 2], [1 -2] as well as [-1; -2], [0;
> 2], [1; -2] to no avail.
>
> drawPolygon(POLYS) - I looked up cell arrays, but none of the notation I've
> tried has worked here.
>
> My goal is to draw a triangle at the given coordinates and then draw it
> again on the same plot using a different color after applying a linear
> transformation to rotate it. Any help or guidance anyone can offer would be
> greatly appreciated.
>
> Thanks,
> Tony
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-octave
>

Hi Anthony,

I can't check right now, but my guess is, for the second way to call
drawPolygon, PX stands for the x coordinates of your polygon, and PY
stands for the y coordinates of the polygon, so, try something like:
PX = [-1 0 1];
PY = [-2 2 -2];
drawPolygon(PX, PY);

Hope this helps.

James Sherman

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help drawing a polygon using drawPolygon

NJank
In reply to this post by Anthony Andriano
On Tue, Feb 21, 2017 at 7:47 AM, Anthony Andriano
<[hidden email]> 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.

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help drawing a polygon using drawPolygon

Doug Stewart-4
In reply to this post by Anthony Andriano


On Tue, Feb 21, 2017 at 7:47 AM, Anthony Andriano <[hidden email]> 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.

I'm trying to draw a triangle with the coordinates (-1, -2), (0, -2), and (1, -2). The documentation for drawPolygon suggests it can take a list of coordinates or some type of array, but I can't find any examples or explanations for how the data should be entered and nothing I've tried has worked.

drawPolygon(COORD) - what does it mean to 'pack' coords into a single array? How does one accomplish this?

drawPolygon(PX, PY) - how do you specify the coordinates in different arrays? I tried passing in [-1 -2], [0 2], [1 -2] as well as [-1; -2], [0; 2], [1; -2] to no avail.

drawPolygon(POLYS) - I looked up cell arrays, but none of the notation I've tried has worked here.

My goal is to draw a triangle at the given coordinates and then draw it again on the same plot using a different color after applying a linear transformation to rotate it. Any help or guidance anyone can offer would be greatly appreciated.

Thanks,
Tony

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

 a= [ 1 1 ; 2 3; 4 2]
drawPolygon(a)


px=[-1 2 6 -1]
py=[-3 4 -1 -3]
drawPolygon(px',py')
--
DASCertificate for 206392


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help drawing a polygon using drawPolygon

Anthony Andriano
Thanks for the help everyone. I was close it seems, but I didn't understand the syntax of any of the options, so none of them worked quite right. Now everything looks perfect.

On Tue, Feb 21, 2017 at 8:06 AM, Doug Stewart <[hidden email]> wrote:


On Tue, Feb 21, 2017 at 7:47 AM, Anthony Andriano <[hidden email]> 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.

I'm trying to draw a triangle with the coordinates (-1, -2), (0, -2), and (1, -2). The documentation for drawPolygon suggests it can take a list of coordinates or some type of array, but I can't find any examples or explanations for how the data should be entered and nothing I've tried has worked.

drawPolygon(COORD) - what does it mean to 'pack' coords into a single array? How does one accomplish this?

drawPolygon(PX, PY) - how do you specify the coordinates in different arrays? I tried passing in [-1 -2], [0 2], [1 -2] as well as [-1; -2], [0; 2], [1; -2] to no avail.

drawPolygon(POLYS) - I looked up cell arrays, but none of the notation I've tried has worked here.

My goal is to draw a triangle at the given coordinates and then draw it again on the same plot using a different color after applying a linear transformation to rotate it. Any help or guidance anyone can offer would be greatly appreciated.

Thanks,
Tony

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

 a= [ 1 1 ; 2 3; 4 2]
drawPolygon(a)


px=[-1 2 6 -1]
py=[-3 4 -1 -3]
drawPolygon(px',py')
--
DASCertificate for 206392



_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: help drawing a polygon using drawPolygon

NJank
In reply to this post by James Sherman
fyi i uploaded a patch added some clarifying text on input format to
the function documentation
https://savannah.gnu.org/bugs/index.php?50370

On Tue, Feb 21, 2017 at 9:34 AM, James Sherman Jr. <[hidden email]> wrote:

> On Tue, Feb 21, 2017 at 7:47 AM, Anthony Andriano
> <[hidden email]> 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.
>>
>> I'm trying to draw a triangle with the coordinates (-1, -2), (0, -2), and
>> (1, -2). The documentation for drawPolygon suggests it can take a list of
>> coordinates or some type of array, but I can't find any examples or
>> explanations for how the data should be entered and nothing I've tried has
>> worked.
>>
>> drawPolygon(COORD) - what does it mean to 'pack' coords into a single array?
>> How does one accomplish this?
>>
>> drawPolygon(PX, PY) - how do you specify the coordinates in different
>> arrays? I tried passing in [-1 -2], [0 2], [1 -2] as well as [-1; -2], [0;
>> 2], [1; -2] to no avail.
>>
>> drawPolygon(POLYS) - I looked up cell arrays, but none of the notation I've
>> tried has worked here.
>>
>> My goal is to draw a triangle at the given coordinates and then draw it
>> again on the same plot using a different color after applying a linear
>> transformation to rotate it. Any help or guidance anyone can offer would be
>> greatly appreciated.
>>
>> Thanks,
>> Tony
>>
>> _______________________________________________
>> Help-octave mailing list
>> [hidden email]
>> https://lists.gnu.org/mailman/listinfo/help-octave
>>
>
> Hi Anthony,
>
> I can't check right now, but my guess is, for the second way to call
> drawPolygon, PX stands for the x coordinates of your polygon, and PY
> stands for the y coordinates of the polygon, so, try something like:
> PX = [-1 0 1];
> PY = [-2 2 -2];
> drawPolygon(PX, PY);
>
> Hope this helps.
>
> James Sherman
>
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-octave

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave