POV-Ray : Newsgroups : povray.general : Something like "nearest neighbour"? Server Time
17 Nov 2024 13:18:07 EST (-0500)
  Something like "nearest neighbour"? (Message 1 to 2 of 2)  
From: Tim Nikias v2 0
Subject: Something like "nearest neighbour"?
Date: 18 Mar 2003 13:05:43
Message: <3e775ff7@news.povray.org>
I'm a little stuck on my wave-system. What I'd
need is an algorithm which takes an object, like
a sphere, and maps it onto a two-dimensional array
of points, to find which points the sphere hits.

The problem is, I'd want the algorithm to do this
for ANY shape, even ones without well-defined
insides (like meshes).

I've thought of several approaches so far, and the best
yet would probably be to shoot one ray from the center
of the object onto the waterplane, and then successively
move outward in order to find the most-outward points
that are hit by the object.

But how to begin that? The plane isn't necessarily
aligned to an axis, so I need a way to "ping" the nearest
point of the array to the position the ray has hit.

Any suggestions?

I've begun looking for "nearest neighbour", but until now
I've only found the "travelling salesman problem", which
is not what I'm looking for.

Any help would be appreciated,
Tim

--
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde


Post a reply to this message

From: Tim Nikias v2 0
Subject: Re: Something like "nearest neighbour"?
Date: 18 Mar 2003 13:39:45
Message: <3e7767f1$1@news.povray.org>
Never mind. I've just thought of a way to do it:

Take the point I want to map onto the grid. Calculate
the intersection of a line passing through that given
point (using the normal of the plane) and the water-plane.
Dissect the intersection-point with the span-vectors,
and calculate their lengths. Divide lengths by respective
distance between nodes. Round the results, and voila!
I got the indices for the nearest node.

I'm a little proud of myself. :-)
Anyone know if this algorithm already exists, or if there
is a faster way?

--
Tim Nikias v2.0
Homepage: http://www.digitaltwilight.de/no_lights
Email: Tim### [at] gmxde


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.