POV-Ray : Newsgroups : povray.general : I was disappointed with six lines : Re: I was disappointed with six lines Server Time
8 Aug 2024 06:14:41 EDT (-0400)
  Re: I was disappointed with six lines  
From: Wlodzimierz ABX Skiba
Date: 8 May 2001 10:51:00
Message: <3af807d4@news.povray.org>
Nekar Xenos wrote in message <3af7f31f@news.povray.org>...
> >vlength(S-E)?B:2*S-B);
> >sphere{<B.y,-B.x,B.z>,.1,1}
>
> I don't understand the use of '?' and 'B.y'

in your original sig there was assigment
#local B=B-(2*(B-S))*((vlength(B-E)>vlength(S-E)));
expression vlength(B-E)>vlength(S-E) is logical
and can return 1 (true) or 0 (false)
therefore you can change it to:
  #if(vlength(B-E)>vlength(S-E))
    #local B=B-2*(B-S)*1;
  #else
    #local B=B-2*(B-S)*0;
  #end
and it is eqivalent of:
  #if(vlength(B-E)>vlength(S-E))
    #local B=B-2*(B-S);
  #else
    #local B=B;
  #end
now, you must know that construction
A?B:C is eqivalent to #if(A) B #else C #end
such equivalent is very popular in programing
(not only POV script language)
(it is described in POV manual under "Float Expressions")
therefore you can write just
#local B=(vlength(B-E)<vlength(S-E)?B:2*S-B);

I have also changed condition for while
from #while(vlength(B-E)>.1) to #while((E-B).x>.1)

Considering that you are going from B to E
you can take length between B and E
but you can also take segment BE
and take one of coordinates

> Could you maybe explain it to me?

Do you need something more ?

> Thanks for all your help :)


Thanks for fun :)

ABX


Post a reply to this message

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