Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dirty Little Tricks

0 views
Skip to first unread message

Jack Ritter

unread,
Jun 7, 1989, 9:25:18 PM6/7/89
to
I've come up with a fast, approximation to
3D Euclidian distance ( sqrt(dx*dx+dy*dy+dz*dz) ).
(It's probably not original, but .....)

1) find these 3 values: abs(dx), abs(dy), abs(dz).

2) Sort them (3 compares, 0-3 swaps)

3) Approx E.D. = max + (1/4)med + (1/4)min.
(error: +/- 13%)

max + (5/16)med + (1/4)min has 9% error.
max + (11/32)med + (1/4)min has 8% error.

As you can see, only shifts & adds are used, and
it can be done with integer arithmetic.
It could be used in ray tracing as a preliminary
test before using the exact form.

We all have our dirty little tricks.

--
-> B O Y C O T T E X X O N <-
Jack Ritter, S/W Eng. Versatec, 2710 Walsh Av, Santa Clara, CA 95051
Mail Stop 1-7. (408)982-4332, or (408)988-2800 X 5743
UUCP: {ames,apple,sun,pyramid}!versatc!ritter

0 new messages