Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Basic General > Freebasic/Qbasi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 647 of 674
Post > Topic >>

Freebasic/Qbasic - passing values for function?

by Janne Lepola <janne.lepola@[EMAIL PROTECTED] > Jan 26, 2008 at 07:49 PM

I'm having trouble with accessing pointInPoly function after changing my 
type structure:

'Type pt2d
'  x As Integer
'  y As Integer
'End Type

'Dim As Integer x,y

'Dim Shared As pt2d poly(20)

Type Poly
         Dim PolyName As String
         Dim PolyX(0 To 10) As Integer
         Dim PolyY(0 To 10) As Integer
         Dim numOfFaces As Integer
End Type

Dim Shared As Poly PolyArray()
Redim PolyArray(0 To 10)

Function ptinpoly(npol As Integer,pv As pt2d Ptr , p1 As pt2d) As Integer
   Dim As Integer i, j, c
   c=0
   For j=0 To npol-1
    i=iif(j=npol-1,0,j+1 )
    If ((((pv[i].y<=p1.y) And (p1.y<pv[j].y)) Or ((pv[j].y<=p1.y) And  _
        (p1.y<pv[i].y))) And (p1.x < (pv[j].x - pv[i].x) * _
        (p1.y - pv[i].y) / (pv[j].y - pv[i].y) + pv[i].x)) Then c = Not c
   Next
   Return c
End Function

....
If ptinpoly(4,@[EMAIL PROTECTED]
(0),polyArray(4)) = -1 Then
   Print "point is inside polygon!"
End If

As you can see, I gave up older p2td -type and wrote new "poly" type. 
All my polygons have only four points currently, so thats why I'm using 
4 as static pointer for pointInside -function.

How should I change my code so that I can pass polygons X/Y info for 
pointInPoly function. What changes are needed for function to work once 
more?

Force is not strong enough yet on This One... I would greatly 
appriaciate solution for this simple, but yet annoying problem :)
 




 2 Posts in Topic:
Freebasic/Qbasic - passing values for function?
Janne Lepola <janne.le  2008-01-26 19:49:30 
Re: Freebasic/Qbasic - passing values for function?
"Tom Lake" <  2008-01-28 08:09:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Jul 6 15:55:34 CDT 2008.