 Author Topic: please help  (Read 129 times)

23452

• Jr. Member
•  • Posts: 72
•  « on: December 21, 2012, 06:07:55 PM »
Can someone help with this code. It checks if an object is in-front of another by only using slops. There are some glitches with the logic(namely using exactly .5pi and 1.5pi), but the idea works on paper.

Code: [Select]
DIM ac AS SINGLE
DIM ao AS SINGLE
DIM a AS SINGLE
DIM w AS SINGLE

check = 0
INPUT "a ", a
INPUT "w ", w
INPUT "y ", y
INPUT "x ", x
ex = 0
ey = 0
cy = 1
cx = 1

'get slopes
ao = (y - ey) / (x - ex)
ac = (y - cy) / (x - cx)

'cheack code for object
IF ao < TAN(a) THEN
check1 = 1
ELSE check1 = 0
END IF

IF ao > TAN(a + w) THEN
check2 = 1
ELSE check2 = 0
END IF

'cheack code for cheack
IF ac < TAN(a) THEN
check3 = 1
ELSE check3 = 0
END IF

IF ac > TAN(a + w) THEN
check4 = 1
ELSE check4 = 0
END IF

'cheack if codes are the same
IF check1 = check3 THEN
IF check2 = check4 THEN
check = 1
END IF
END IF

PRINT check, check1, check2, check3, check4

Gorlock

• Sr. Member
•    • Posts: 337
•  « Reply #1 on: December 22, 2012, 11:26:03 AM »
Could you give a little more information. I'm not sure what the variables stand for. I am not sure where you are using pi/2 or 3pi/2 but pi is 4*ATN(1) so you can use 2*ATN(1) for pi/2 and 6*ATN(1) for 3pi/2. When you add more information I can probably help you more.

23452

• Jr. Member
•  • Posts: 72
•  