|
|
hello,
any body can help me to translate c function to poc sdl ?
here is the routine :
---------------------------------------------------------------------------
int no_interior( p1, p2, p3, v, vp, n, poly_or )
int p1, p2, p3; /* The vertices to consider */
vertex v[]; /* The vertex list */
int vp[]; /* The vertex pointers (which are left) */
int n; /* Number of vertices */
int poly_or; /* Polygon orientation */
{
int i; /* Iterative counter */
int p; /* The test point */
for (i = 0; i < n; i++) {
p = vp[i]; /* The point to test */
if ((p == p1) || (p == p2) || (p == p3))
continue; /* Don't bother checking against yourself */
if ( (determinant( p2, p1, p, v ) == poly_or)
|| (determinant( p1, p3, p, v ) == poly_or)
|| (determinant( p3, p2, p, v ) == poly_or) ) {
continue; /* This point is outside */
} else {
return 0; /* The point is inside */
}
}
return 1; /* No points inside this triangle */
}
---------------------------------------------------------------------------
v[] and vp[] exist and there declared as array].
i have to problems :
- 'continue' doesn't exist in pov (and is good)
- 'return val' too (and is good too).
ideas ?
greats thanks
Post a reply to this message
|
|
|
|
Kurts <kur### [at] yahoofr> wrote:
> int no_interior( p1, p2, p3, v, vp, n, poly_or )
> int p1, p2, p3; /* The vertices to consider */
> vertex v[]; /* The vertex list */
> int vp[]; /* The vertex pointers (which are left) */
> int n; /* Number of vertices */
> int poly_or; /* Polygon orientation */
K&R-style C? Where did you get this?-)
> {
> int i; /* Iterative counter */
> int p; /* The test point */
> for (i = 0; i < n; i++) {
> p = vp[i]; /* The point to test */
> if ((p == p1) || (p == p2) || (p == p3))
> continue; /* Don't bother checking against yourself */
> if ( (determinant( p2, p1, p, v ) == poly_or)
> || (determinant( p1, p3, p, v ) == poly_or)
> || (determinant( p3, p2, p, v ) == poly_or) ) {
> continue; /* This point is outside */
> } else {
> return 0; /* The point is inside */
> }
> }
> return 1; /* No points inside this triangle */
> }
> ---------------------------------------------------------------------------
> v[] and vp[] exist and there declared as array].
> i have to problems :
> - 'continue' doesn't exist in pov (and is good)
> - 'return val' too (and is good too).
'continue' doesn't have any useful purpose in that piece of code anyways.
The first 'continue' can be removed by simply negating the if condition, and
the second 'continue' is completely obsolete (it doesn't do anything at all).
The 'return 0' is slightly more complicated, but there's a clever trick to
implement it cleanly in pov-SDL.
I will use uppercase variables here to avoid collision with internal
keywords. I will also assume that you have already implemented determinant()
as a macro which returns whatever it has to return.
#macro no_interior( P1, P2, P3, V, VP, N, poly_or )
#local I = 0;
#local retVal = 1;
#while(I < N & retVal = 1)
#local P = VP[I];
#if(!(P=P1 | P=P2 | P=P3))
#if(!(determinant(P2, P1, P, V) = poly_or |
determinant(P1, P3, P, V) = poly_or |
determinant(P3, P2, P, V) = poly_or))
#local retVal = 0;
#end
#end
#local I = I+1;
#end
retVal
#end
--
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -
Post a reply to this message
|
|
|
|
In article <3f6c3363@news.povray.org>, Warp <war### [at] tagpovrayorg> wrote:
> ...
> ...
> 'continue' doesn't have any useful purpose in that piece of code anyways.
> The first 'continue' can be removed by simply negating the if condition, and
> the second 'continue' is completely obsolete (it doesn't do anything at all).
> The 'return 0' is slightly more complicated, but there's a clever trick to
> implement it cleanly in pov-SDL.
>
> I will use uppercase variables here to avoid collision with internal
> keywords. I will also assume that you have already implemented determinant()
> as a macro which returns whatever it has to return.
> ...
> ...
merci merci
ok about collisions with internal keyword. here is just the original c source.
and yes, i have already implemented determinant() macro.
one again, thankssssss
Post a reply to this message
|
|