#### 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 SINGLEDIM ao AS SINGLEDIM a AS SINGLEDIM w AS SINGLEcheck = 0INPUT "a ", aINPUT "w ", wINPUT "y ", yINPUT "x ", xex = 0ey = 0cy = 1cx = 1'get slopesao = (y - ey) / (x - ex)ac = (y - cy) / (x - cx)'cheack code for objectIF ao < TAN(a) THEN    check1 = 1ELSE check1 = 0END IFIF ao > TAN(a + w) THEN    check2 = 1ELSE check2 = 0END IF'cheack code for cheackIF ac < TAN(a) THEN    check3 = 1ELSE check3 = 0END IFIF ac > TAN(a + w) THEN    check4 = 1ELSE check4 = 0END IF'cheack if codes are the sameIF check1 = check3 THEN    IF check2 = check4 THEN        check = 1    END IFEND IFPRINT 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.

• Jr. Member
• Posts: 72