 # Thread: Graphing a Line Problem (Math)

1. ## Graphing a Line Problem (Math)

I'm trying to create an invisible line formed by the direction an object is facing and its current hotspot, and when the Y value of another object is greater than a spot on that line (determined by that object's X position), then "do something." In this case, I just made it paste to the background repeatedly so I can see where the math actually draws the line. I'm not sure how to make this work, and what I do have works even worse at different angles. Any help would be appreciated.

An example .mfa is attached for what I've gotten so far.  Reply With Quote

2. ...  Reply With Quote

3. Something like this?  Reply With Quote

4. Pretty close, ya. I think I might be able to use that, but just speculating. The only problem I have with that is that it looks like it requires a detector object, and testing the Y position of the object that changes colors has to be aligned with that detector and changes colors based on the hotspot instead of possibly being above or below a line drawn by a direct path to the rotating object and the detector object.

What I'm trying to make can't move so freely.

--- After testing that out further, it still doesn't work.  Reply With Quote

5. We know the formula for a straight line is: Y = MX + C

To find M (the gradient), we use trigonometry:
M = (0-Sin(Angle( "Line" )))/Cos(Angle( "Line" ))

To find C (the intercept), we rearrange the original formula, and substitute the X and Y coordinates of a point we know is somewhere along the line (we can use the line object's hotspot).

C = Y( "Line" )-(M*X( "Line" ))

Now that we know both M and C, we can solve for Y:

If Y position of Object < (M*X( "Object" ))+C
...then the object is above the line.

eg.
http://skydrive.live.com/redir?resid...094271BBDA!544  Reply With Quote

6. Exactly what I needed! Thank you, kind sir. You are a gentleman and a scholar!  Reply With Quote

#### Tags for this Thread

graph, intercept, line, math, tangent #### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•