.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #1  
Old November 26th, 2004, 08:56 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default OT: 2D/3D math

Anyone know how to determine the closest point on a line to a point? Rapidly running out of ideas...

Thanks.
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #2  
Old November 26th, 2004, 10:10 PM
Aiken's Avatar

Aiken Aiken is offline
Major
 
Join Date: Jan 2004
Location: Taganrog, Russia
Posts: 1,087
Thanks: 0
Thanked 0 Times in 0 Posts
Aiken is on a distinguished road
Default Re: OT: 2D/3D math

crossing of perpendicular from this point with a line itself?
Reply With Quote
  #3  
Old November 26th, 2004, 10:15 PM
Slick's Avatar

Slick Slick is offline
Brigadier General
 
Join Date: Apr 2002
Location: Kailua, Hawaii
Posts: 1,860
Thanks: 0
Thanked 1 Time in 1 Post
Slick is on a distinguished road
Default Re: OT: 2D/3D math

yeah for 2D:

line: Ax + By + C = 0
Point: (x1, y1)

[saving you the gory details]

Code:


|Ax1 + By1 + C|
distance between point and line: D = -----------------
square root (A^2 + B^2)



notation: | | is absoute value, ^2 is raised to power 2


For 3D, it takes a little more...


Slick.
__________________
Slick.
Reply With Quote
  #4  
Old November 26th, 2004, 11:03 PM
TerranC's Avatar

TerranC TerranC is offline
Brigadier General
 
Join Date: Dec 2001
Posts: 1,859
Thanks: 0
Thanked 0 Times in 0 Posts
TerranC is on a distinguished road
Default Re: OT: 2D/3D math

Mathematics! Formulas! Variables! Discussion!

Run away! Run away! Math is taking over the world!
__________________
A* E* Se++ GdQ $ Fr! C Csc Sf+ Ai- M Mp* S++ Ss- R! Pw Fq Nd Rp+ G++ Mm+ Bb++ Tcp+ L Au

Download Sev Today! --- Download BOB and SOCk today too! --- Thanks to Fyron and Trooper for hosting.

Reply With Quote
  #5  
Old November 26th, 2004, 11:15 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: 2D/3D math

Code:


|Ax1 + By1 + C|
distance between point and line: D = -----------------
square root (A^2 + B^2)



So...
Code:


|A*x1 + B*y1 + C|
distance between point and line: D = -----------------
square root (A^2 + B^2)



??

In that case, what are A, B and C?
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #6  
Old November 26th, 2004, 11:20 PM
Slick's Avatar

Slick Slick is offline
Brigadier General
 
Join Date: Apr 2002
Location: Kailua, Hawaii
Posts: 1,860
Thanks: 0
Thanked 1 Time in 1 Post
Slick is on a distinguished road
Default Re: OT: 2D/3D math

use some algebra to transform the equation of the line to:

line: Ax + By + C = 0

then use whatever you came up with for A, B & C in the formula I gave to find the distance between the point and the line.

Slick.
__________________
Slick.
Reply With Quote
  #7  
Old November 26th, 2004, 11:30 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: 2D/3D math

Or, you know, I could do that thing I almost never think of and explain myself...

I'm programming. I have the start XY of the line, the end XY of the line and the XY of the point. And I have no idea how to teach a computer algebra derivation.
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #8  
Old November 26th, 2004, 11:56 PM
Aiken's Avatar

Aiken Aiken is offline
Major
 
Join Date: Jan 2004
Location: Taganrog, Russia
Posts: 1,087
Thanks: 0
Thanked 0 Times in 0 Posts
Aiken is on a distinguished road
Default Re: OT: 2D/3D math

If P1(x1,y1) - startpoint
and P2(x2,y2) - endpoint
Then equation of the line will be:
x*(y2-y1) - y*(x2-x1) - x1*y2 + x2*y1 = 0

so A = y2-y1; B = -(x2-x1); C = -(x1*y2 - x2*y1).

But how to find coordinates of the point in the cross of line and perpendicular?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.