Distance between a 3D point and a vector defined by two 3D points
$begingroup$
Drawing of the vector and line
I have vector points A (Xa, Ya, Za) and B (Xb, Yb, Zb)
Point to measure the distance from;
C (Xc, Yc, Zc)
I don't know if it's correct, but this is my equation for distance: D = (|(C-A) * (C-B)|) / (|B-A|)
Can I split that formula to:
Dx = (|(Xc-Xa) * (Xc-Xb)|) / (|Xb-Xa|)
Dy = (|(Yc-Ya ) * (Yc-Yb)|) / (|Yb-Ya|)
Dz = (|(Zc-Za) * (Zc-Zb)|) / (|Zb-Za|)
, to get the X distance, Y distance and Z distance from the point to vector?
If that equation is even correct.
I'm pretty insecure since I'm still in high school and don't know much about 3D math. Would really appreciate if you helped me out or gave me a better solution if there is one. (This is for game programming purposes)
trigonometry 3d
$endgroup$
add a comment |
$begingroup$
Drawing of the vector and line
I have vector points A (Xa, Ya, Za) and B (Xb, Yb, Zb)
Point to measure the distance from;
C (Xc, Yc, Zc)
I don't know if it's correct, but this is my equation for distance: D = (|(C-A) * (C-B)|) / (|B-A|)
Can I split that formula to:
Dx = (|(Xc-Xa) * (Xc-Xb)|) / (|Xb-Xa|)
Dy = (|(Yc-Ya ) * (Yc-Yb)|) / (|Yb-Ya|)
Dz = (|(Zc-Za) * (Zc-Zb)|) / (|Zb-Za|)
, to get the X distance, Y distance and Z distance from the point to vector?
If that equation is even correct.
I'm pretty insecure since I'm still in high school and don't know much about 3D math. Would really appreciate if you helped me out or gave me a better solution if there is one. (This is for game programming purposes)
trigonometry 3d
$endgroup$
$begingroup$
Does*
refer to the cross product here? If so, it's still not quite correct. You want the distance from C to the line going through AB?
$endgroup$
– Dylan
Dec 13 '18 at 16:53
$begingroup$
Are you looking for the distance to the line through $A$ and $B$ or to the line segement $overline{AB}$? If the latter, then you also have to deal with the case that the perpendicular from $C$ doesn’t intersect the segment at all.
$endgroup$
– amd
Dec 13 '18 at 18:02
add a comment |
$begingroup$
Drawing of the vector and line
I have vector points A (Xa, Ya, Za) and B (Xb, Yb, Zb)
Point to measure the distance from;
C (Xc, Yc, Zc)
I don't know if it's correct, but this is my equation for distance: D = (|(C-A) * (C-B)|) / (|B-A|)
Can I split that formula to:
Dx = (|(Xc-Xa) * (Xc-Xb)|) / (|Xb-Xa|)
Dy = (|(Yc-Ya ) * (Yc-Yb)|) / (|Yb-Ya|)
Dz = (|(Zc-Za) * (Zc-Zb)|) / (|Zb-Za|)
, to get the X distance, Y distance and Z distance from the point to vector?
If that equation is even correct.
I'm pretty insecure since I'm still in high school and don't know much about 3D math. Would really appreciate if you helped me out or gave me a better solution if there is one. (This is for game programming purposes)
trigonometry 3d
$endgroup$
Drawing of the vector and line
I have vector points A (Xa, Ya, Za) and B (Xb, Yb, Zb)
Point to measure the distance from;
C (Xc, Yc, Zc)
I don't know if it's correct, but this is my equation for distance: D = (|(C-A) * (C-B)|) / (|B-A|)
Can I split that formula to:
Dx = (|(Xc-Xa) * (Xc-Xb)|) / (|Xb-Xa|)
Dy = (|(Yc-Ya ) * (Yc-Yb)|) / (|Yb-Ya|)
Dz = (|(Zc-Za) * (Zc-Zb)|) / (|Zb-Za|)
, to get the X distance, Y distance and Z distance from the point to vector?
If that equation is even correct.
I'm pretty insecure since I'm still in high school and don't know much about 3D math. Would really appreciate if you helped me out or gave me a better solution if there is one. (This is for game programming purposes)
trigonometry 3d
trigonometry 3d
asked Dec 13 '18 at 16:35
Marin KovačMarin Kovač
52
52
$begingroup$
Does*
refer to the cross product here? If so, it's still not quite correct. You want the distance from C to the line going through AB?
$endgroup$
– Dylan
Dec 13 '18 at 16:53
$begingroup$
Are you looking for the distance to the line through $A$ and $B$ or to the line segement $overline{AB}$? If the latter, then you also have to deal with the case that the perpendicular from $C$ doesn’t intersect the segment at all.
$endgroup$
– amd
Dec 13 '18 at 18:02
add a comment |
$begingroup$
Does*
refer to the cross product here? If so, it's still not quite correct. You want the distance from C to the line going through AB?
$endgroup$
– Dylan
Dec 13 '18 at 16:53
$begingroup$
Are you looking for the distance to the line through $A$ and $B$ or to the line segement $overline{AB}$? If the latter, then you also have to deal with the case that the perpendicular from $C$ doesn’t intersect the segment at all.
$endgroup$
– amd
Dec 13 '18 at 18:02
$begingroup$
Does
*
refer to the cross product here? If so, it's still not quite correct. You want the distance from C to the line going through AB?$endgroup$
– Dylan
Dec 13 '18 at 16:53
$begingroup$
Does
*
refer to the cross product here? If so, it's still not quite correct. You want the distance from C to the line going through AB?$endgroup$
– Dylan
Dec 13 '18 at 16:53
$begingroup$
Are you looking for the distance to the line through $A$ and $B$ or to the line segement $overline{AB}$? If the latter, then you also have to deal with the case that the perpendicular from $C$ doesn’t intersect the segment at all.
$endgroup$
– amd
Dec 13 '18 at 18:02
$begingroup$
Are you looking for the distance to the line through $A$ and $B$ or to the line segement $overline{AB}$? If the latter, then you also have to deal with the case that the perpendicular from $C$ doesn’t intersect the segment at all.
$endgroup$
– amd
Dec 13 '18 at 18:02
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Let $theta$ be the angle between the vectors $overrightarrow{AC}$ and $overrightarrow{AB}$. Then, the distance, i.e. the length of the perpendicular drawn from $C$ to $AB$ is
$$d = vertoverrightarrow{AC}vertsintheta$$
You also know the cross product
$$ vertoverrightarrow{AC} times overrightarrow{AB}vert = vertoverrightarrow{AC}vertvertoverrightarrow{AB}vertsintheta $$
therefore
$$ d = frac{vert overrightarrow{AC} times vec{AB} vert}{vertvec{AB}vert} $$
EDIT: To find the perpendicular vector, consider the projection vector of $overrightarrow{AC}$ on the line $AB$. Let's call this $overrightarrow{D}$. Then its length is given by
$$ vertoverrightarrow{AD}vert = vertoverrightarrow{AC}vertcostheta = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert} $$
where the dot product identity was used. Since $overrightarrow{AD}$ is in the same direction as $overrightarrow{AB}$, you can find its coordinates by "scaling" $overrightarrow{AB}$, i.e.
$$ overrightarrow{AD} = vert overrightarrow{AD} vert frac{overrightarrow{AB}}{vertoverrightarrow{AB}vert} = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert^2} overrightarrow{AB}$$
The perpendicular vector, $overrightarrow{DC}$, is computed by the difference
$$ overrightarrow{DC} = overrightarrow{AC} - overrightarrow{AD} $$
The 3 components of $overrightarrow{DC}$ are the $x$, $y$, $z$ distances you're looking for.
$endgroup$
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3038257%2fdistance-between-a-3d-point-and-a-vector-defined-by-two-3d-points%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Let $theta$ be the angle between the vectors $overrightarrow{AC}$ and $overrightarrow{AB}$. Then, the distance, i.e. the length of the perpendicular drawn from $C$ to $AB$ is
$$d = vertoverrightarrow{AC}vertsintheta$$
You also know the cross product
$$ vertoverrightarrow{AC} times overrightarrow{AB}vert = vertoverrightarrow{AC}vertvertoverrightarrow{AB}vertsintheta $$
therefore
$$ d = frac{vert overrightarrow{AC} times vec{AB} vert}{vertvec{AB}vert} $$
EDIT: To find the perpendicular vector, consider the projection vector of $overrightarrow{AC}$ on the line $AB$. Let's call this $overrightarrow{D}$. Then its length is given by
$$ vertoverrightarrow{AD}vert = vertoverrightarrow{AC}vertcostheta = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert} $$
where the dot product identity was used. Since $overrightarrow{AD}$ is in the same direction as $overrightarrow{AB}$, you can find its coordinates by "scaling" $overrightarrow{AB}$, i.e.
$$ overrightarrow{AD} = vert overrightarrow{AD} vert frac{overrightarrow{AB}}{vertoverrightarrow{AB}vert} = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert^2} overrightarrow{AB}$$
The perpendicular vector, $overrightarrow{DC}$, is computed by the difference
$$ overrightarrow{DC} = overrightarrow{AC} - overrightarrow{AD} $$
The 3 components of $overrightarrow{DC}$ are the $x$, $y$, $z$ distances you're looking for.
$endgroup$
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
add a comment |
$begingroup$
Let $theta$ be the angle between the vectors $overrightarrow{AC}$ and $overrightarrow{AB}$. Then, the distance, i.e. the length of the perpendicular drawn from $C$ to $AB$ is
$$d = vertoverrightarrow{AC}vertsintheta$$
You also know the cross product
$$ vertoverrightarrow{AC} times overrightarrow{AB}vert = vertoverrightarrow{AC}vertvertoverrightarrow{AB}vertsintheta $$
therefore
$$ d = frac{vert overrightarrow{AC} times vec{AB} vert}{vertvec{AB}vert} $$
EDIT: To find the perpendicular vector, consider the projection vector of $overrightarrow{AC}$ on the line $AB$. Let's call this $overrightarrow{D}$. Then its length is given by
$$ vertoverrightarrow{AD}vert = vertoverrightarrow{AC}vertcostheta = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert} $$
where the dot product identity was used. Since $overrightarrow{AD}$ is in the same direction as $overrightarrow{AB}$, you can find its coordinates by "scaling" $overrightarrow{AB}$, i.e.
$$ overrightarrow{AD} = vert overrightarrow{AD} vert frac{overrightarrow{AB}}{vertoverrightarrow{AB}vert} = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert^2} overrightarrow{AB}$$
The perpendicular vector, $overrightarrow{DC}$, is computed by the difference
$$ overrightarrow{DC} = overrightarrow{AC} - overrightarrow{AD} $$
The 3 components of $overrightarrow{DC}$ are the $x$, $y$, $z$ distances you're looking for.
$endgroup$
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
add a comment |
$begingroup$
Let $theta$ be the angle between the vectors $overrightarrow{AC}$ and $overrightarrow{AB}$. Then, the distance, i.e. the length of the perpendicular drawn from $C$ to $AB$ is
$$d = vertoverrightarrow{AC}vertsintheta$$
You also know the cross product
$$ vertoverrightarrow{AC} times overrightarrow{AB}vert = vertoverrightarrow{AC}vertvertoverrightarrow{AB}vertsintheta $$
therefore
$$ d = frac{vert overrightarrow{AC} times vec{AB} vert}{vertvec{AB}vert} $$
EDIT: To find the perpendicular vector, consider the projection vector of $overrightarrow{AC}$ on the line $AB$. Let's call this $overrightarrow{D}$. Then its length is given by
$$ vertoverrightarrow{AD}vert = vertoverrightarrow{AC}vertcostheta = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert} $$
where the dot product identity was used. Since $overrightarrow{AD}$ is in the same direction as $overrightarrow{AB}$, you can find its coordinates by "scaling" $overrightarrow{AB}$, i.e.
$$ overrightarrow{AD} = vert overrightarrow{AD} vert frac{overrightarrow{AB}}{vertoverrightarrow{AB}vert} = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert^2} overrightarrow{AB}$$
The perpendicular vector, $overrightarrow{DC}$, is computed by the difference
$$ overrightarrow{DC} = overrightarrow{AC} - overrightarrow{AD} $$
The 3 components of $overrightarrow{DC}$ are the $x$, $y$, $z$ distances you're looking for.
$endgroup$
Let $theta$ be the angle between the vectors $overrightarrow{AC}$ and $overrightarrow{AB}$. Then, the distance, i.e. the length of the perpendicular drawn from $C$ to $AB$ is
$$d = vertoverrightarrow{AC}vertsintheta$$
You also know the cross product
$$ vertoverrightarrow{AC} times overrightarrow{AB}vert = vertoverrightarrow{AC}vertvertoverrightarrow{AB}vertsintheta $$
therefore
$$ d = frac{vert overrightarrow{AC} times vec{AB} vert}{vertvec{AB}vert} $$
EDIT: To find the perpendicular vector, consider the projection vector of $overrightarrow{AC}$ on the line $AB$. Let's call this $overrightarrow{D}$. Then its length is given by
$$ vertoverrightarrow{AD}vert = vertoverrightarrow{AC}vertcostheta = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert} $$
where the dot product identity was used. Since $overrightarrow{AD}$ is in the same direction as $overrightarrow{AB}$, you can find its coordinates by "scaling" $overrightarrow{AB}$, i.e.
$$ overrightarrow{AD} = vert overrightarrow{AD} vert frac{overrightarrow{AB}}{vertoverrightarrow{AB}vert} = frac{overrightarrow{AC}cdot overrightarrow{AB}}{vert overrightarrow{AB} vert^2} overrightarrow{AB}$$
The perpendicular vector, $overrightarrow{DC}$, is computed by the difference
$$ overrightarrow{DC} = overrightarrow{AC} - overrightarrow{AD} $$
The 3 components of $overrightarrow{DC}$ are the $x$, $y$, $z$ distances you're looking for.
edited Dec 14 '18 at 6:50
answered Dec 13 '18 at 16:59
DylanDylan
12.4k31026
12.4k31026
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
add a comment |
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
Thank you very much! Just to be sure, for x distance, I can take x values of the points, for y distance, I take y and for z distance, I take z values of points?
$endgroup$
– Marin Kovač
Dec 13 '18 at 19:26
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
@MarinKovač It doesn't work like that. You need all 3 coordinates to compute the cross product. The result is just the total distance. What you're asking is finding the perpendicular vector from C to AB, which is entirely different.
$endgroup$
– Dylan
Dec 14 '18 at 6:39
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
I added some more information on the perpendicular vector. Hopefully you know how to compute the cross and dot products.
$endgroup$
– Dylan
Dec 14 '18 at 6:52
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
$begingroup$
Thanks, that helped. :D
$endgroup$
– Marin Kovač
Dec 14 '18 at 13:31
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3038257%2fdistance-between-a-3d-point-and-a-vector-defined-by-two-3d-points%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Does
*
refer to the cross product here? If so, it's still not quite correct. You want the distance from C to the line going through AB?$endgroup$
– Dylan
Dec 13 '18 at 16:53
$begingroup$
Are you looking for the distance to the line through $A$ and $B$ or to the line segement $overline{AB}$? If the latter, then you also have to deal with the case that the perpendicular from $C$ doesn’t intersect the segment at all.
$endgroup$
– amd
Dec 13 '18 at 18:02