POV-Ray : Newsgroups : povray.general : Looking for a formula : Re: Looking for a formula Server Time
29 Jul 2024 10:20:48 EDT (-0400)
  Re: Looking for a formula  
From: Kenneth
Date: 18 Feb 2013 21:15:01
Message: <web.5122de0e24d8606ec2d977c20@news.povray.org>
scott <sco### [at] scottcom> wrote:

>
> You shouldn't be using a direction vector as a parameter for the
> cylinder primitive...
>
> Much clearer to write it like this:
>
> #declare trace_shoot_from = <-2,9,0>; // line start point
> #declare trace_shoot_to = <18,-8,0>; // i.e., the line end point
> #declare trace_shoot_direction = vnormalize(trace_shoot_to -
> trace_shoot_from);
> ...
> trace(target_object,trace_shoot_from,trace_direction,norm);
> ...
> cylinder{trace_shoot_from,trace_shoot_to, .1}

Hmm, that DOES work...and always hits the correct two-line intersection. Nicely
done! To re-word my own phrase, and using your idea, "...trace's 'direction'
vector CAN dynamically change to always point at a particular location in
space." The general idea, although probably not the right words.

In looking at your code, it occurred to me that I've actually used this very
thing in the past; don't know how I could have forgotten it so easily. Maybe
because useful code snippets/ideas can get 'lost' when not used on a regular
basis. My excuse, anyway...  :-/

This results in my orange and green cylinders being like so..
// ORANGE--
cylinder{trace_shoot_from,trace_shoot_to, .1}

// GREEN--
cylinder{trace_shoot_from,trace_shoot_to, .1}

Identical!--which at first I thought couldn't be right. But yes, it's correct.

BTW, looking back at our posts here shows me that I misunderstood one of your
suggestions...

> Define a cylinder between points A and B with a small radius.
> Use the trace command to trace from point C in direction (D-C) ... etc.

I mistook that for a shorthand way of simply saying "D *TO* C" rather than "D
MINUS C".

Sorry for the bit of confusion--and thanks for clarifying it with the fix.


Post a reply to this message

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