I came into this piece of C code (I think) to check whether it is within a point or not A well-organized method is considered to be a (concave or convex) polygon and want to use it in its JS program:
Testx, float testy) {int i, j, c = 0; (I = 0, j = nvert-1; i & lt; nvert; j = i ++) {if (((poverty (i)> test) = (poverty [j]> accessory)) ; Amp; (testx & lt; (vertx [j] -vertx [i]) * (testi-dewi [ii]) / (poverty [j] -revery [ii]) + works [ii]) c =! C; } Return C; }
nvert: Number of shorts in polygon Repeat the top first at the end. How will it be translated into JS? I have already figured out how i can start loop in js and I think that float '*' s in the first line can be left in JS but I'm not quite sure that "int I, j, c = 0; "what does or what"! C "means when unlike" c = 0 ". 0? thanks There should be vertical and poverty array and should start those values there vertx = []; poverty = []; Then the function Is very similar (assuming it is correct)
vertx, poverty: Array with X-and Y-coordinates of the corner of the polygon.
testx, testy: X and Y-coordinates of the test point (this is another stack overflow question:). for
j = nvert-1 (i = 0; i
function pnpoly (var nvert, var vertx, var verty, var testx, var testy). {Var i, j, c = 0; For (i = 0, j = nvert-1; i & lt; nvert; j = i ++) {if (((poverty (i)> mess!) = (Poverty [j]> exam) & amp; ; Amp; amp; (TestX & lt; (vertx [j] -Works [ii]) * (Examiner -River [I]) / (poverty [J] -rivri [i]) + Works [i])) c! = C;}
No comments:
Post a Comment