Pomoc w znalezieniu rozumowania

0

mam oto taki post

Closest point on a line to another line in 3D		 	 


	 kuroioranda    Member since: 4/16/2007


 Posted - 1/8/2009 7:29:59 PM
Assuming two lines in 3D space that may or may not intersect (definied by points of origin and direction vectors, really a ray), how do I determine what the closest point on line A to line B is? I understand how to find the closest point on a line to a discrete point, but having to solve for an unknown point on a line has me stumped.


 User Rating: 1024   |  Rate This User 		Report this Post to a Moderator | Link



	 hallucinogenic    Member since: 7/15/2004  From: Vancouver, Canada


 Posted - 1/8/2009 8:30:46 PM
If you define your lines as follows (parameterized vector functions):

A(s) = PA1 + (PA2 - PA1)s
B(t) = PB1 + (PB2 - PB1)t

Then the distance between your two lines is:

D(s, t) = B(t) - A(s)

From calculating the distance of a point to a line, we know that the closest point occurs when the vector from the point on the line to the point in space is perpendicular to the direction of the line.

Similarly, this must be the case for two lines, too. However, it must be maintained for *both* lines.

Let La = (PA2 - PA1),
Lb = (PB2 - PB1)

Thus, La . D(s, t) = 0, and
Lb . D(s, t) = 0

Substituting, we get:

La . (B(t) - A(s)) = 0, and
Lb . (B(t) - A(s)) = 0

Expanding, we get:

La . ( (PB1 - PA1) + Lb * t - La * s) ) = 0, and
Lb . ( (PB1 - PA1) + Lb * t - La * s) ) = 0

Expanding again, we get:

La . (PB1 - PA1) + La . Lb * t - La . La * s = 0, and
Lb . (PB1 - PA1) + Lb . Lb * t - Lb . La * s = 0

Finally, rearranging the equation, we end up with:

(La . La)s - (La . Lb)t = La . (PB1 - PA1), and
(La . Lb)s - (Lb . Lb)t = Lb . (PB1 - PA1)

This is a system of equations in s and t that should be easy enough to solve.

Chodzi dokladnie o ostatnie linijki

Finally, rearranging the equation, we end up with:

(La . La)s - (La . Lb)t = La . (PB1 - PA1), and
(La . Lb)s - (Lb . Lb)t = Lb . (PB1 - PA1)

Za cholere nie moge pojacco to jest (La . La) itp. coto jest ta kropka i czy zamiast La mam podstawic (PA2 - PA1) nie kumam tego prosilbym o pomoc :]

0
  1. Istnieje <quote> i </quote>, które pasuje tu lepiej od <code class="cpp"> i </code>...
  2. Kropka to iloczyn skalarny, to przecież od razu widać z tych równań, skoro masz tam: Wektor . Wektor = 0 to w 1 klasie liceum już każdy powinien zauważyć że masz tu iloczyn skalarny.
  3. Zastanów się czego właściwie szukasz i co tak na prawdę chcesz policzyć ;)
0

ja rfozumie ze jak ktos nie odroznia kolorow to dla niego ten caly zielony tekst wyglada tak samo ale ja wole miec poformatowany i pokolorwany tekst i uwierz mi ze go sie lepiej czyta niz quote

0
  1. Quote nie psuje formatowania tekstu
  2. Pokolorowane słowa kluczowe c++ pomagają ci w czytaniu zwykłego tekstu? Masz zadatki na prawdziwego haxora :D

// ad2 poprawiłem na Quote - Qyon

1 użytkowników online, w tym zalogowanych: 0, gości: 1