POV-Ray : Newsgroups : povray.general : Looking for a formula Server Time
29 Jul 2024 12:19:13 EDT (-0400)
  Looking for a formula (Message 31 to 35 of 35)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Kenneth
Subject: Re: Looking for a formula
Date: 16 Feb 2013 14:50:01
Message: <web.511fe18424d8606ec2d977c20@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:

>
> While *special* values can be chosen for both lines' end points to produce
> a trace that looks like a perfect 'hit' at the intersection, it's not really
> so.

Sorry, that didn't clearly express what I meant.  Reworded:

"While particular values CAN be chosen for both lines' start/end points to
produce a trace that *looks like* a perfect hit at the intersection, the result
is most likely not very accurate."

Also...

>
> // A sphere to indicate the found position. (If this ends up AT the
> // origin, then the trace ray has totally missed the target line.)
> #if(vlength(norm) !=0)
> sphere{0,.35
> no_shadow
> pigment{rgb 1*<.3,1,1>}
> translate found_position
> }
> #else
> #end
>

It's probably better to leave out the #if/#else/#end; then a trace ray that
misses the target will actually SHOW the sphere at the origin.


Post a reply to this message

From: Kenneth
Subject: Re: Looking for a formula
Date: 16 Feb 2013 15:00:01
Message: <web.511fe4f924d8606ec2d977c20@news.povray.org>
"Samuel Benge" <stb### [at] hotmailcom> wrote:

>
> Sorry if that sent you off on a tangent!

Funny! ;-)


Post a reply to this message

From: scott
Subject: Re: Looking for a formula
Date: 18 Feb 2013 03:18:20
Message: <5121e3cc$1@news.povray.org>
> // ORANGE--the other line. These are the start and end points, which
> // are also used in trace().
> #declare trace_shoot_from = <-2,9,0>;
> #declare trace_direction = <18,-8,0>; // i.e., the line end point

?? The above line really confused me, the trace direction is not the 
line end point. The trace direction is the difference between the start 
and end point (and possibly normalized too to make it clear it's a 
direction).

> // ORANGE--The other line--which might be imagined to be the trace
> // ray direction, but is not.
> cylinder{trace_shoot_from,trace_direction, .1
> no_shadow
> pigment{rgb 1*<1,.7,0>}
> }

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}


Post a reply to this message

From: Kenneth
Subject: Re: Looking for a formula
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

From: scott
Subject: Re: Looking for a formula
Date: 19 Feb 2013 03:13:31
Message: <5123342b@news.povray.org>
> 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.

The direction vector that trace needs is purely a direction, like a 
heading in geography (eg north-east or 45 degrees) - it doesn't contain 
any information about location in the scene. Trace will then start at 
the "start position" you specify and fire a ray in the direction you 
specify.

If you want the ray to pass through a certain point then you can 
calculate the direction like I did, by taking the difference between the 
point you want it to pass through and the start point.

> 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...  :-/

Perfectly valid excuse :-) Most of my scenes involve plenty of 
copying&pasting from previous scenes, it's much faster than trying to 
look up how to use certain features again (this is where an IDE like the 
one Mike Raiford was developing would be really helpful).

> 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".

OK yes that would get things backwards - sorry for the confusion! 
Nothing beats posting actual code :-)


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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