On 14/12/2013 6:52 AM, Raul Miller wrote:
The script just shows a pallete - like for a paint program. It's a
draft, and some components are overly complex or mislabeled (for
example the "tri" routine actually draws polygons - sometimes
triangles, sometimes hexagons). But basically, imagine a "color cube".
This is a unit cube where coordinates in the cube correspond to
colors. 0 0 0 is black, 1 1 1 is white, 1 0 0 is red, 0 1 0 is green
and 0 0 1 is blue.
Got it.
Now take this cube and rotate it so that the white/black axis is
tangent to the plane defined by the screen. Then take 256 evenly
spaced slices of the cube along that axis. Those slices are my "color
palettes". The center slice is approximately a regular hexagon while
slices towards the white and black end of the slider (I have a slider
to choose which slice to display) are equilateral triangles.
That is somewhat messier.
Everything else is just implementation.
The particular bit of code we are discussing here is a part of a
sorting algorithm. I generate vertex locations for all of the corners
of all of those color cube slices, but the order which I generate them
in is not useful for rendering them in the opengl api. So I first
group them based on their position on the white/black axis and then I
use the "gift wrap" convex hull algorithm to order them.
I know that these points already form a convex hull - I do not need to
discard any of them. So I just arbitrarily pick a point and then work
through the remaining points, finding the point with the largest angle
with respect to the last picked point and an arbitrary frame of
reference and marking it as the next point to use.
And that's what this -@^.@rms bit is doing - finding that angle.
What you have noted threw me (NB.root mean square)isn't that but is a
root (sum of squares) -really a 'distance'.
(on a plane for the white-black point fixed) between points - apparently
angles in this case (although the original example gave
a magnitude rather than an angle)
and you are then getting the log of 1/this distance.
However, not having ground through your work (and maybe not yet
competent enough in J to do so) I am missing a lot
Is there a need to use -^. or -log rather than the raw "distance"?
As for meaning - meaning is something we assign to observations.
Whether it's useful or not depends on our tastes and goals (and this
can involve a fair bit of experimentalism and thought sometimes).
Agreed - and a curse/benefit of J is that there are so many different
ways to handle a problem
Thanks to you,
Don
Thanks,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm