Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / How would I convert this C++ algorithm to Dark Basic Pro

Author
Message
Programmer X
17
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 25th Jan 2014 22:57 Edited at: 26th Jan 2014 01:39
int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
{
int i, j, c = 0;
for (i = 0, j = nvert-1; i < nvert; j = i++) {
if ( ((verty>testy) != (verty[j]>testy)) &&
(testx < (vertx[j]-vertx) * (testy-verty) / (verty[j]-verty) + vertx) )
c = !c;
rem R commands would replace above.
}
return c;
}


I want to convert the X and y to a u and v angle on a sphere then change R# by

R#=R(Minimum)
[Length of minimum R]
R#=R#/(sin(90-(umax#-ustep#))/sin(90-ustep#))
update ru from distance to rmin
R#=R#/(sin(90-(vmax#-vstep#))/sin(90-vstep#))
update rv from distance to rmin

Have it follow a line between two points

XXX
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 27th Jan 2014 00:14
That code looks sketchy... verty is an array of floats, and you compare it's address to testy (which is also a float, while the address would be a DWORD or a QWORD).
I'm going to assume that's a typo and you meant to compare verty[j] to testy, however it happens in several places.
Can you elaborate on that, is that really supposed to be part of the algorithm...?

As for converting it to DBPro, it should be relatively straight forward; the not operator (!= in C++) is <> in DBPro, "&&" is AND and not (!) is not, however I'm not quite sure if it works the same as the C version of that operator; I would hazard a guess you'll be safer just replacing it with "= 0".

As for passing arrays to functions you can either use IanM's array pointers and pass those, use two global arrays or allocate a dynamic memory buffer (make memory or alloc; the latter is from M1U again and has quite better features than the first). The last approach with a pointer to memory makes it easy to write recursive functions where you can offset the pointer and call the function with that new pointer as an argument.


"Why do programmers get Halloween and Christmas mixed up?"
Programmer X
17
Years of Service
User Offline
Joined: 14th Nov 2007
Location:
Posted: 29th Jan 2014 02:37
http://www.ecse.rpi.edu/~wrf/Research/Short_Notes/pnpoly.html

XXX

Login to post a reply

Server time is: 2024-11-18 21:51:47
Your offset time is: 2024-11-18 21:51:47