POV-Ray : Newsgroups : povray.off-topic : 99 lines of C++ for an unbiased ray tracer : Re: 99 lines of C++ for an unbiased ray tracer Server Time
4 Sep 2024 23:22:58 EDT (-0400)
  Re: 99 lines of C++ for an unbiased ray tracer  
From: Warp
Date: 14 Jan 2010 14:38:41
Message: <4b4f72c1@news.povray.org>
Tim Cook <z99### [at] gmailcom> wrote:
> scott wrote:
> >> 53:  Vec nl=n.dot(r.d)<0?n:n*-1;
> >>
> >> different from "nl = -abs(n.dot(r.d))"?
> > 
> > a?b:c evaluates to b if a is true, or c otherwise.

> LPC might be a little different, but can't you negate a variable by 
> saying a=-a;?  Saves a little CPU cost.

  Yes, but since 'nl' is of type struct Vec, he would have to define
operator-() for it for that to work. Maybe he wanted to save one line
of code.

-- 
                                                          - Warp


Post a reply to this message

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