POV-Ray : Newsgroups : povray.general : Looking for a formula : Re: Looking for a formula Server Time
29 Jul 2024 10:22:12 EDT (-0400)
  Re: Looking for a formula  
From: Kenneth
Date: 15 Feb 2013 17:20:01
Message: <web.511eb0e224d8606ec2d977c20@news.povray.org>
scott <sco### [at] scottcom> wrote:
> > I now realize what the problem is...
>
> Sorry it doesn't make sense to me.
>

It *is* a bit of a brain-twister, I admit.

The situation is probably best illustrated by a simple test scene.  (It took a
test *animation* for me to clearly see it; but here it's just a static scene.)
And I've arranged things in an even simpler way than might occur normallly, for
clarity: the two lines (which naturally have to be on the same plane for an
intersection to even occur, statistically speaking) are both on the vertical
plane running through the origin, -x to +x.

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.

The wild card is trace's shoot-from point (which represents any arbitrary
beginning point of the non-target line.) If that value is anything other than a
'special case', the found point (the traced point) doesn't coincide with the
true intersection. That's because of the unchanging nature of trace's
'direction' vector. (BTW, trace 'normalizes' that vector, I think.)

The RED cylinder is the target line; ORANGE is the other line (where trace
starts, and with the unchanging end point used as trace's 'direction');
GREEN is the *actual* trace direction--which almost never coincides with the
orange line.

Plug in different values for the orange line's y ('trace_shoot_from') to see
what happens; this represents any naturally arbitrary value for that line's
start point. You might also see the 'parallel' concept I mentioned (more easily
seen with an orthgraphic camera placed in -z).

The real key to understanding all this is that trace's 'direction' vector
doesn't automatically/dynamically change to always point at a particular
location in space.

------
global_settings {assumed_gamma 2.2}

camera {
  perspective
  location  <-4, 8, -20>
  look_at   <8, 0,  0>
  right     x*image_width/image_height
  angle 67
}

light_source {
  <0, 0, 0>
  color rgb <1, 1, 1>
  translate <-30, 30, -30>
}

light_source {
  <0, 0, 0>
  color rgb <1, 1, 1>
  translate <30, 30, -30>
}

background{rgb .7}

plane{y,0 pigment{rgbt <.8,.9,1,.3>}}

// ----------------------------------------
// RED--The 'target' line
#declare target_line_start_point = <5,-12,0>;
#declare target_line_end_point = <9,10,0>;

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

#declare norm = <0,0,0>;

#declare target_object =
cylinder{target_line_start_point,target_line_end_point, .2}

#declare found_position =
trace(target_object,trace_shoot_from,trace_direction,norm);

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

// RED--the 'target' cylinder
object{target_object
no_shadow
pigment{rgb 1*<1,.3,.3>}
}

// 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>}
}

// GREEN--this CORRECTLY illustrates the trace ray direction...
cylinder{trace_shoot_from,found_position, .1
no_shadow
pigment{rgb 1.2*<.3,1,0>}
}

// the origin axes
union{
// X axis
cylinder{-40*x,40*x,.05}
// Y axis
cylinder{0,3*y,.05}
// Z axis
cylinder{-5*z,5*z,.05}
 no_shadow
 pigment{rgb .3}
}


Post a reply to this message

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