Advertisement

difficult vector problem

Started by February 28, 2003 01:52 AM
16 comments, last by CProgrammer 21 years, 11 months ago
Say i have 3 Vectors. v, b, f, n f perpendicular b. n = v+f; now i want n to be scaled so that the following is still true: |n| = |v| and The komponent of n parallel to b must equal the komponent of v parallel to b; so: (v.b/|b|^2)*b=(n.b/|b|^2)*b I need this for a simulation i''m making. Thanks for any ideas. -CProgrammer
Just make f the zero vector It will be orthogonal to b and |v+f|=|v|=|n| will be true.
Keys to success: Ability, ambition and opportunity.
Advertisement
v, b, f are calculated every frame and vary.
You cannot change them to get the solution to my problem.
However b is perpendicular f and don''t forget the component parallel to b must be the same for v and n.

Any answers guys

-CProgrammer
quote:
Original post by CProgrammer
n = v+f;
|n| = |v|



n = v+f;

lenV = v.length();
lenN = n.length();

n *= lenV/lenN;

if this vector n doesn''t fulfill your other requests, you can''t solve all your requests anyway...
-----The scheduled downtime is omitted cause of technical problems.
Sorry thats not it either cause n doesnt have the same projection onto b as v does in your answer.
I think one must find a vector x which when added to the parallel komponent of n equals n(scaled). In addition one finds multiple equations and then uses these to specifie x;
But I can''t figure it out.
quote:

if this vector n doesn''t fulfill your other requests, you can''t solve all your requests anyway...



OmniBrain:Well I think theres a soulution but i have no garanty on that.

-CProgrammer
My Website
What do you mean by "scaling" n? Normally scaling a vector means to multiply it with a scalar. If that''s the case there is no way to solve your problem unless |n| = |v| from the start.
Advertisement
...or if n is perpendicular to b...
Youre right scaling was a bad therm.
I just want n to be modifed in such a way that the requests are met. In what way doesn''t matter.
So n could be any vector such that |n| = |v| and n.b = v.b? Then just set n = v.
You have an infinite number of solutions.
n.b = v.b constrains n to lie in the same plane as v with b as its normal. The constraint n = v + f with f orthogonal to b is automatically satisfied since n and v already lie in a plane perpendicular to b. The constraint |n| = |v| means n and v lie in a circle. Thus n = v is a solution, and so is n = 2(b.v/b.b)b - v. In 2d, these are the only solutions, otherwise you have the whole circle.
Do you have any more constraints, or more information about the problem?

"Math is hard" -Barbie
"Math is hard" -Barbie

This topic is closed to new replies.

Advertisement