POV-Ray : Newsgroups : povray.binaries.images : tractor 2008 (164k jpg) : Re: tractor 2008 (164k jpg) Server Time
30 Jul 2024 20:28:11 EDT (-0400)
  Re: tractor 2008 (164k jpg)  
From: Edouard Poor
Date: 7 Dec 2008 17:55:01
Message: <web.493c537262d2e221245002290@news.povray.org>
stbenge <THI### [at] hotmailcom> wrote:

> Hi Edouard,
>
> I thought using the "i" word might get somebody to think of a solution
> :) I tried the macro, and it seems to work very well. It's not as slow
> as I thought it would be! I'm not sure if I understand the code
> completely. It traces lines through the mesh, and if the number of
> intersections is odd, it considers the point of reference inside, right?

Exactly - odd means the point was inside.

I, too, was surprised how fast it was - I didn't really notice being slower on
the test scenes you bundled with your macro.

> I don't have any formal schooling in higher math, so I do not understand
> this line:
>
> (mod( num, 2 ) = 1)
>
> The POV docs say mod(A,B) returns the remainder of the integer division
> of A/B. I can understand that. But how does this work when you say it
> equals 1? Is this like a conditional statement?

The statement gets evaluated to true or false (which is one or zero in POV SDL).
Once the "mod(num,2)" has been evaluated, the statement then becomes "0=1" or
"1=1" which in turn evaulates to 0 or 1 (i.e. false or true).

It's being used like a shorthand for an if() statement. I'm a C++ programmer,
and it's a very common idiom in that language, so I guess it's second nature to
me, and I didn't think that it wouldn't be as clear to an SDL programmer. Sorry!

> May I use your code in my next distribution of my proximity macros? I'll
> give you credit, of course :)

Most certainly! Your macros are a wonder, and amazingly useful.

> Sam

Cheers,
Edouard.


Post a reply to this message

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