The Daily Click ::. Forums ::. Klik Coding Help ::. Projecting a point onto a line
 

Post Reply  Post Oekaki 
 

Posted By Message

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
23rd January, 2008 at 19:33:10 -

Ok I've honestly forgotten this since high school, and I can't find a good example on wikipedia or anywhere. What I want to do, is have a point (the player), which will be projected onto a 1-dimensional plane of a line between 2 points. So when I run the editor, I have 3 different locations on a cartesian grid, and I want to project the 3rd to where it would meet the other 2 on a line, at a 90 degree adjacent to it. Pretty much this picture:
Image

I've been remaking my gravity engine as an open sourcer, and this is dead vital. I need the center of gravity for longer objects to always be directly beneath the player's feet as you walk down it. This is very very simple to do on a simple vertical or horizontal axis (set X = constant, Y = Yplayer, etc), but proving difficult for oddly angled objects.

If I got this down, I could create platforms you could walk across at ANY angle, with proper physics.

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
23rd January, 2008 at 19:33:50 -

And the fact that TGF runs in the wrong quadrant for Sin/Cos equations makes this difficult (need to invert Y)

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
23rd January, 2008 at 20:35:55 -

its not just tgf. in computing x increases as it goes left to right y increases as it goes top to bottom.
i have so many math books and i remember this problem as well. don't really wanna dig for the answer

 
n/a

nim



Registered
  17/05/2002
Points
  7233
23rd January, 2008 at 21:07:19 -

Maybe this will be useful: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/

That looks like a rather unfriendly formula on that page, and I'd imagine that it'll look a complete mess when it's in TGF... Hope that's what you're looking for.

 
//

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
23rd January, 2008 at 21:25:56 -

thats good only if he knows 4 coordinates. 2 on each line equation. he only has 3 and he wants the perpendicular line that goes through his third coordinate, and intersects the line that goes through the first 2. im working it out right now so all the equations are in terms of the three coordinates. (x1, y1) (x2, y2) (x3, y3). itll give you the x and y of the unknown intersection point. hold on a second.

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
23rd January, 2008 at 22:29:42 -

Image

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
24th January, 2008 at 14:44:21 -

Oooh very very much thanks, that could prove incredibly helpful. I'll go and alter my SMG engine before it gets accepted

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
24th January, 2008 at 14:53:45 -

btw theres a game on TIGS called frozzd that works almost exactly like what youre doing. also inspired by smg.
http://www.tigsource.com/articles/search?q=frozzd

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
24th January, 2008 at 17:44:09 -

http://www.create-games.com/download.asp?id=7011

If you wanna check it out, minus the neat projection stuff right now

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
   

Post Reply



 



Advertisement

Worth A Click