No, I defined plotxy() in the code; it isn't part of GD. I only included it in Closure, omitted elsewhere since it's redundant to include it three times in the post.
As for the two lines...
If $xy =
[[4,5,6],[4,5,6]], scalar(@{$xy->
[0]}) = scalar(@{$xy->
[0]}) = 3, the number of elements.
$xy->
[0] points to the first array in $xy; $xy->
[1] second.
@{$xy->
[0]} dereferences $xy->
[0] into an array.
So, $xy->
[0][scalar(@{$xy->[0]})] will be like $xy->
[0][3], the new element in the array, yet to be defined, since the index of the last position is 2.
$d*sin(PI*$h/180) is just some transformation stuff from trigonometry/geometry/calculus.
$#{@{$xy->
[0]}} gives you the index of the last element, which is 2 in this example.
So, $xy->
[0][$#{@{$xy->[0]}}] = $xy->
[0][$#{@{$xy->[1]}}] gives you 6.
(I've noticed you have "...$+#..." in your reply. When you see
+ in a code in the post, it indicates a continuation from the previous line. When you cut and past codes, those
+ might be inadvertently included. Remember to remove them.)
Hence, the two lines basically say,
new x coordinate = distance (on x axis) from old x coordinate + old x coordinate
new y coordinate = distance (on y axis) from old y coordinate + old y coordinate
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.