POV-Ray : Newsgroups : povray.documentation.inbuilt : Lathe and Prism updates requested by Christoph. : Re: Lathe and Prism updates requested by Christoph. Server Time
20 Apr 2024 01:19:06 EDT (-0400)
  Re: Lathe and Prism updates requested by Christoph.  
From: William F Pokorny
Date: 26 May 2016 20:11:30
Message: <574790b2$1@news.povray.org>
On 05/26/2016 11:56 AM, Le_Forgeron wrote:
> Le 26/05/2016 00:53, Jim Holsenback a écrit :
>
> Thanks for your time :-)
>
> I'm going to be painful, hopefully not to much for Jim, but other(s):
>
> what is "clockwise" and "counterClockwise" ?
>
> And before someone jumps in to state the obvious, think again about it.
>
> Usually (Danger Will Robinson, Danger), +X is to the right and +Y is up.
>
> And the direction of Z when going 3D is a holy war between left-hand and right-hand
system.
>
> But it is not unusual either that +X is to the right and +Y is down (many pictures
format have such convention).
> (origin at top left, and in fact, western-text has that same convention: Nth lines,
Mth character on that line)
>
> And some tenants of right-hand system like +X to the left, +Y up and +Z away (and
most 3D formats are rather right-handed... at least STL is strongly thought as such)
>
> I also want to stress that it is topologically, and logically too, impossible to
define left/right with an alien over a radio link: even using physical laws to have
the same experiment. You can define down and up (gravity is helpful), you can define
away and nearer, but,
> as the alien's environment might be matter or anti-matter, you cannot use anything
to provide the same definition of left & right.
> And if you cannot define left/right, clockwise and counterclockwise are lost too.
>
> All this, to ask for more explanation, or illustration, of "clockwise" and
"counterClockwise".
>

I'm not opposed to making things clearer. I was aiming for wording I 
thought most would easily understand, while conforming somewhat to 
conventions.

The clockwise vs counter-clockwise concept is used commonly for 2D 
geometric algorithms and the lathe and prism spline point lists are 2D. 
In the case of the lathe we are working in a normally defined x,y plane. 
In the case of prisms we are working in a normally defined x,z plane.

There are different ways to make the determination, but for splines 
which form closed loop(s), a counter-clockwise loop would be one such 
that the sum over all the loop edges of (x2-x1)*(y2+y1) is negative. 
Points inside a counter-clockwise loop of edges are considered to be 
inside the shape. A clockwise loop reverses the points to shape 
relationship.

In the case of lathes we can have edge(s) which do not form a closed 
loop. There we chose a point (x3,y3) to the left of an edge and look at 
the determinant (cross product) :

(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1).

If the value returned is >0, the 'edge-by-direction' is 
counter-clockwise with respect to the test point and the test point is 
considered to be inside. If <0 the test point is considered outside. If 
exactly 0, the test point is collinear with the edge.

POV-Ray today follows the above clockwise vs counter-clockwise 2D 
conventions for determining inside vs outside everywhere except for the 
bezier spline in the prism, where, the inside and outside conventions 
are reversed for the prism sides. Further, all prism ends point outward 
no matter the loop order.

Asides: There are degenerate, fringe point lists which will also fall 
outside these 2D conventions, but I think users will not often deal with 
them. The 2d clockwise vs counter-clockwise conventions are used mostly 
with what is our linear spline. Of course for prisms replace y with z in 
the equations above.

So, I guess the question is do we:

- add some or all the text above about 2d clockwise / counter-clockwise 
conventions?

- add some figures explicitly showing the two example point lists or 
others showing what would be clockwise and counter-clockwise point lists 
with respect to inside/outside determination?

- change to more generic wording like 'orientation' and 'reverse 
orientation' without any suggestions about normal, normal directions but 
noting they flip.

- simply note that point list order matters to surface normal 
determination in lathes and prisms and leave it at that? Starting to 
feel like I have wandered off into the weeds... :-)

Thoughts?

Bill P.


Post a reply to this message

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