Skip to main content
GameDev.net gamedev.net
🔒 Locked

difficult vector problem

Started by CProgrammer Feb 28, 2003 at 1:52 AM 16 replies 450+ views
Original Post
CProgrammer
CProgrammer
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
LilBudyWizer
LilBudyWizer
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.
CProgrammer
CProgrammer
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
OmniBrain
OmniBrain
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.
CProgrammer
CProgrammer
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
CProgrammer
CProgrammer
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.
Pragma
Pragma
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
LilBudyWizer
LilBudyWizer
I''m confused as to why OmniBrain''s answer isn''t right. |n*|v|/|n||=|v|. So if n=|v|*(v+f)/|(v+f) then |n|=|v|. If n=v+f and you want |n|=|v|, but don''t want to change n, v or f then it is either true or it isn''t. It will only be true if (f/2).(v-f/2)=0. Then |f| is the base of an isoceles trangle, |v-f/2| is its height and the angle between them is 90 degrees.
Keys to success: Ability, ambition and opportunity.
sQuid
sQuid
You have |n | = |v | = |v + f |

Another way of writing this is

v .v = (v + f ).(v + f )

or v .f = 0.5 * |f |2

Is this satisfied for your given f and v ?

If so, then n = (v .b ) b / |b | - (v .f ) f / |f | should do it.

Edit: oops, this is what LilBudyWizer said

[edited by - sQuid on February 28, 2003 11:00:44 PM]
CProgrammer
CProgrammer
LilBudyWizer: The reason why OmniBrains and your solution are not what im looking for is the following:

First of i am talking of 3d-Vectors here i guess i wasn''t to clear on that my apologizes.
Secondly the equation:
n=|v|*(v+f)/|(v+f)
meets |n|=|v|
however not my second request:
the komponent of the vector v parallel to b must have the same Length as that of n parallel to b.
In other words:
|proj_b_v| = |proj_b_n|
|v.b|/|b|=|n.b|/|b|

I think this part was misunderstood:
n = v+f;

After assigning n this value n must be MODFIED to meet the requests. Being |n| = |v| it should then NOT be |n| = |v+f|
this should no longer be true due to the modification.
|n| = |v| and |proj_b_v| = |proj_b_n| should be true for the modified n. The reason i want n modified to the givin requests is cause the more similar n is to v+f with the requests the better.

Thanks for all the replies
Hope its clearer now

-CProgrammer
LilBudyWizer
LilBudyWizer
My first answer was just a joke and a mistaken conclusion from the problem statement. I also mistakenly assumed the last part of an observation to assist in solving the problem rather than a condition of the solution and ignored it.

I think you are going to need to restate the problem to get a solution. It might help to explain it in terms of what you are trying to accomplish rather than mathematical properties of the solution. You are doing a simulation and how does this fit in. Is v your velocity, f a force, b your binormal and n your normal? If so then f seems to point the wrong direction. n should point to the outside of the curve while f points to the inside.
Keys to success: Ability, ambition and opportunity.
CProgrammer
CProgrammer
The simulation shows the movement of an electron in the field of two point like magnets.
v is the velocity
f is the Lorenz force
b is the vector specifieng strength of magnet and direction in the given frame.
n is the new velocity vector after all effects have taken place.

Calculating this problem with physical standards does not work. The resulting vector using the standard proceadure of physiks is n.
n = v+f/m*deltaT;
where m is the mass of an elektron.
To simplify i made m and deltaT 1 so
n = v+f;
f, b are calculated every frame and are therefore given.

all i want now is that n be changed to meet the demands, for through only doing v+f n will increase in length every frame. If i only scale it to v''s length it slows down in the parallel direction to b.
Therefore n must be changed to meet the two requests.

Hope its clear now.

-CProgrammer
Fruny
Fruny
The problem is inherent to your usage of Euler integration, which doesn't take into accout the effects of the force field on the path between two frames.

V = (vx, 0, vz)
B = (0, 0, 1 )
q = 1
m = 1

Thus F = q V*B = (0, vx, 0)
Apply the force over a duration t.

V' = (vx, vx*t, vz)

Scaling V' back to V will unfortunately affect vz too.

The only real solution is to use a better numeric integration method. Fourth-order Runge-Kutta is typically used in such cases. Look it up in any good numerical methods textbook.

However, a ugly hack, which will only work in this very specific case exists : work with the projection of V onto the plance normal to B.

Vb = B*(V.B)/|B|^2
V1 = V - Vb
V2 = V1 + F
V3 = V2 * |V1|/|V2|
V' = V3 + Vb

It will break pathetically (or rather, produce completely wrong results) if your magnetic field is non-uniform. (And don't forget to take into account the field produced by the moving particle itself ... aaaaah the joys of electrodynamics )



[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]


[edited by - Fruny on March 1, 2003 11:23:25 PM]

[edited by - Fruny on March 1, 2003 11:29:06 PM]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
CProgrammer
CProgrammer
Thanks Fruny.
The magnetic field is non-uniform.
Thanks for the tip i''ll look up
Fourth-order Runge-Kutta
and i''ll try to figure it out with that.

-CProgrammer
CProgrammer
CProgrammer
Oh by the way. In case anybody has a good website on runge kutta or a good example source code similar to my problem please tell me.

-CProgrammer

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.