Vector relative to another vector
$begingroup$
I have a direction vector (x/y/z) that I need to express relative to the normal vector of a surface, such that the direction vector is "local" to the normal vector.
I've read that I need to create a basis using the normal vector (up/right/forward) and use the dot product to find each new vector element.
1.) Is this the most efficient way to calculate the localized direction vector?
2.) How do I then transform the direction vector back into its original basis (after it is altered in local space)?
linear-algebra geometry
$endgroup$
add a comment |
$begingroup$
I have a direction vector (x/y/z) that I need to express relative to the normal vector of a surface, such that the direction vector is "local" to the normal vector.
I've read that I need to create a basis using the normal vector (up/right/forward) and use the dot product to find each new vector element.
1.) Is this the most efficient way to calculate the localized direction vector?
2.) How do I then transform the direction vector back into its original basis (after it is altered in local space)?
linear-algebra geometry
$endgroup$
$begingroup$
The approach you describes seems like generally the right one, but it would be easier to give a good answer if you gave some more specifics about your application (and perhaps establish some notation).
$endgroup$
– arghbleargh
Aug 19 '16 at 20:34
add a comment |
$begingroup$
I have a direction vector (x/y/z) that I need to express relative to the normal vector of a surface, such that the direction vector is "local" to the normal vector.
I've read that I need to create a basis using the normal vector (up/right/forward) and use the dot product to find each new vector element.
1.) Is this the most efficient way to calculate the localized direction vector?
2.) How do I then transform the direction vector back into its original basis (after it is altered in local space)?
linear-algebra geometry
$endgroup$
I have a direction vector (x/y/z) that I need to express relative to the normal vector of a surface, such that the direction vector is "local" to the normal vector.
I've read that I need to create a basis using the normal vector (up/right/forward) and use the dot product to find each new vector element.
1.) Is this the most efficient way to calculate the localized direction vector?
2.) How do I then transform the direction vector back into its original basis (after it is altered in local space)?
linear-algebra geometry
linear-algebra geometry
asked Aug 19 '16 at 16:55
anonymooseanonymoose
112
112
$begingroup$
The approach you describes seems like generally the right one, but it would be easier to give a good answer if you gave some more specifics about your application (and perhaps establish some notation).
$endgroup$
– arghbleargh
Aug 19 '16 at 20:34
add a comment |
$begingroup$
The approach you describes seems like generally the right one, but it would be easier to give a good answer if you gave some more specifics about your application (and perhaps establish some notation).
$endgroup$
– arghbleargh
Aug 19 '16 at 20:34
$begingroup$
The approach you describes seems like generally the right one, but it would be easier to give a good answer if you gave some more specifics about your application (and perhaps establish some notation).
$endgroup$
– arghbleargh
Aug 19 '16 at 20:34
$begingroup$
The approach you describes seems like generally the right one, but it would be easier to give a good answer if you gave some more specifics about your application (and perhaps establish some notation).
$endgroup$
– arghbleargh
Aug 19 '16 at 20:34
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Is this the most efficient way to calculate the localized direction vector?
It depends on how you define "efficient". In general, this is the simplest way, and definitely sufficiently fast in a computer program, even in a game. Whether it is the fastest, depends on the hardware, memory structures available, and so on. This is definitely the way I'd generally do it, for sure.
If you are asking about the nitty gritty details, I'd say you could make the surface normal vector unit vector (by always scaling it to unit length, i.e. 1), and also store the two other basis vector with each surface. That is, rather than calculate them again and again. I'd definitely do this myself.
Let's say you have $hat{n}$ as the normal vector, perpendicular to the surface, with $hat{u}$ and $hat{v}$ parallel to the surface; with all three unit vectors (length $1$), and all three vectors perpendicular to each other. Furthermore, the point on the surface is $vec{p}$, and you wish to find the vector $vec{r}$ from point $vec{p}$ to $vec{q}$, but relative to the point $vec{p}$ on the surface. This is simple:
$$vec{r} = ( x, y, z ) = left ( hat{u} cdot left ( vec{q} - vec{p} right ), ;
hat{v} cdot left ( vec{q} - vec{p} right ), ;
hat{n} cdot left ( vec{q} - vec{p} right ) right )$$
Here, $x$ and $y$ are along the surface, with $z$ increasing above the surface if your normal points outwards; if your normals point inwards, then $z$ decreases as you go further above the surface. $z = 0$ is on the surface in any case.
How do I then transform the direction vector back into its original basis (after it is altered in local space)?
Converting $vec{r}$ back to the global coordinate system is just as easy,
$$vec{q} = vec{p} + x hat{u} + y hat{v} + z hat{n}$$
As to computational efficiency, each conversion requires nine multiplications and nine additions or subtractions, if I calculated right. I would consider that quite efficient; I don't really know how you could reduce that in any way that would matter in practice.
$endgroup$
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%2f1897310%2fvector-relative-to-another-vector%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$
Is this the most efficient way to calculate the localized direction vector?
It depends on how you define "efficient". In general, this is the simplest way, and definitely sufficiently fast in a computer program, even in a game. Whether it is the fastest, depends on the hardware, memory structures available, and so on. This is definitely the way I'd generally do it, for sure.
If you are asking about the nitty gritty details, I'd say you could make the surface normal vector unit vector (by always scaling it to unit length, i.e. 1), and also store the two other basis vector with each surface. That is, rather than calculate them again and again. I'd definitely do this myself.
Let's say you have $hat{n}$ as the normal vector, perpendicular to the surface, with $hat{u}$ and $hat{v}$ parallel to the surface; with all three unit vectors (length $1$), and all three vectors perpendicular to each other. Furthermore, the point on the surface is $vec{p}$, and you wish to find the vector $vec{r}$ from point $vec{p}$ to $vec{q}$, but relative to the point $vec{p}$ on the surface. This is simple:
$$vec{r} = ( x, y, z ) = left ( hat{u} cdot left ( vec{q} - vec{p} right ), ;
hat{v} cdot left ( vec{q} - vec{p} right ), ;
hat{n} cdot left ( vec{q} - vec{p} right ) right )$$
Here, $x$ and $y$ are along the surface, with $z$ increasing above the surface if your normal points outwards; if your normals point inwards, then $z$ decreases as you go further above the surface. $z = 0$ is on the surface in any case.
How do I then transform the direction vector back into its original basis (after it is altered in local space)?
Converting $vec{r}$ back to the global coordinate system is just as easy,
$$vec{q} = vec{p} + x hat{u} + y hat{v} + z hat{n}$$
As to computational efficiency, each conversion requires nine multiplications and nine additions or subtractions, if I calculated right. I would consider that quite efficient; I don't really know how you could reduce that in any way that would matter in practice.
$endgroup$
add a comment |
$begingroup$
Is this the most efficient way to calculate the localized direction vector?
It depends on how you define "efficient". In general, this is the simplest way, and definitely sufficiently fast in a computer program, even in a game. Whether it is the fastest, depends on the hardware, memory structures available, and so on. This is definitely the way I'd generally do it, for sure.
If you are asking about the nitty gritty details, I'd say you could make the surface normal vector unit vector (by always scaling it to unit length, i.e. 1), and also store the two other basis vector with each surface. That is, rather than calculate them again and again. I'd definitely do this myself.
Let's say you have $hat{n}$ as the normal vector, perpendicular to the surface, with $hat{u}$ and $hat{v}$ parallel to the surface; with all three unit vectors (length $1$), and all three vectors perpendicular to each other. Furthermore, the point on the surface is $vec{p}$, and you wish to find the vector $vec{r}$ from point $vec{p}$ to $vec{q}$, but relative to the point $vec{p}$ on the surface. This is simple:
$$vec{r} = ( x, y, z ) = left ( hat{u} cdot left ( vec{q} - vec{p} right ), ;
hat{v} cdot left ( vec{q} - vec{p} right ), ;
hat{n} cdot left ( vec{q} - vec{p} right ) right )$$
Here, $x$ and $y$ are along the surface, with $z$ increasing above the surface if your normal points outwards; if your normals point inwards, then $z$ decreases as you go further above the surface. $z = 0$ is on the surface in any case.
How do I then transform the direction vector back into its original basis (after it is altered in local space)?
Converting $vec{r}$ back to the global coordinate system is just as easy,
$$vec{q} = vec{p} + x hat{u} + y hat{v} + z hat{n}$$
As to computational efficiency, each conversion requires nine multiplications and nine additions or subtractions, if I calculated right. I would consider that quite efficient; I don't really know how you could reduce that in any way that would matter in practice.
$endgroup$
add a comment |
$begingroup$
Is this the most efficient way to calculate the localized direction vector?
It depends on how you define "efficient". In general, this is the simplest way, and definitely sufficiently fast in a computer program, even in a game. Whether it is the fastest, depends on the hardware, memory structures available, and so on. This is definitely the way I'd generally do it, for sure.
If you are asking about the nitty gritty details, I'd say you could make the surface normal vector unit vector (by always scaling it to unit length, i.e. 1), and also store the two other basis vector with each surface. That is, rather than calculate them again and again. I'd definitely do this myself.
Let's say you have $hat{n}$ as the normal vector, perpendicular to the surface, with $hat{u}$ and $hat{v}$ parallel to the surface; with all three unit vectors (length $1$), and all three vectors perpendicular to each other. Furthermore, the point on the surface is $vec{p}$, and you wish to find the vector $vec{r}$ from point $vec{p}$ to $vec{q}$, but relative to the point $vec{p}$ on the surface. This is simple:
$$vec{r} = ( x, y, z ) = left ( hat{u} cdot left ( vec{q} - vec{p} right ), ;
hat{v} cdot left ( vec{q} - vec{p} right ), ;
hat{n} cdot left ( vec{q} - vec{p} right ) right )$$
Here, $x$ and $y$ are along the surface, with $z$ increasing above the surface if your normal points outwards; if your normals point inwards, then $z$ decreases as you go further above the surface. $z = 0$ is on the surface in any case.
How do I then transform the direction vector back into its original basis (after it is altered in local space)?
Converting $vec{r}$ back to the global coordinate system is just as easy,
$$vec{q} = vec{p} + x hat{u} + y hat{v} + z hat{n}$$
As to computational efficiency, each conversion requires nine multiplications and nine additions or subtractions, if I calculated right. I would consider that quite efficient; I don't really know how you could reduce that in any way that would matter in practice.
$endgroup$
Is this the most efficient way to calculate the localized direction vector?
It depends on how you define "efficient". In general, this is the simplest way, and definitely sufficiently fast in a computer program, even in a game. Whether it is the fastest, depends on the hardware, memory structures available, and so on. This is definitely the way I'd generally do it, for sure.
If you are asking about the nitty gritty details, I'd say you could make the surface normal vector unit vector (by always scaling it to unit length, i.e. 1), and also store the two other basis vector with each surface. That is, rather than calculate them again and again. I'd definitely do this myself.
Let's say you have $hat{n}$ as the normal vector, perpendicular to the surface, with $hat{u}$ and $hat{v}$ parallel to the surface; with all three unit vectors (length $1$), and all three vectors perpendicular to each other. Furthermore, the point on the surface is $vec{p}$, and you wish to find the vector $vec{r}$ from point $vec{p}$ to $vec{q}$, but relative to the point $vec{p}$ on the surface. This is simple:
$$vec{r} = ( x, y, z ) = left ( hat{u} cdot left ( vec{q} - vec{p} right ), ;
hat{v} cdot left ( vec{q} - vec{p} right ), ;
hat{n} cdot left ( vec{q} - vec{p} right ) right )$$
Here, $x$ and $y$ are along the surface, with $z$ increasing above the surface if your normal points outwards; if your normals point inwards, then $z$ decreases as you go further above the surface. $z = 0$ is on the surface in any case.
How do I then transform the direction vector back into its original basis (after it is altered in local space)?
Converting $vec{r}$ back to the global coordinate system is just as easy,
$$vec{q} = vec{p} + x hat{u} + y hat{v} + z hat{n}$$
As to computational efficiency, each conversion requires nine multiplications and nine additions or subtractions, if I calculated right. I would consider that quite efficient; I don't really know how you could reduce that in any way that would matter in practice.
answered Aug 19 '16 at 21:28
Nominal AnimalNominal Animal
6,9452517
6,9452517
add a comment |
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%2f1897310%2fvector-relative-to-another-vector%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$
The approach you describes seems like generally the right one, but it would be easier to give a good answer if you gave some more specifics about your application (and perhaps establish some notation).
$endgroup$
– arghbleargh
Aug 19 '16 at 20:34