Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 21st Jun 2010 16:48
hi, i would like to know how to add a vector to another one.
example, i've a point in the space, is not important x y and z coords, but is moving with a force of "M1" with a defined angle x (x1) and a defined angle y (y1), 0 on anlge z.
now, i would like to add another force from this point, a force of value "M2", with its angle x (X2) and y (Y2) and again 0 on angle z.

i need the result of the two vectors, but i don't know how to do it.
the final data will be the new X angle(x3),the new y angle (Y3) and the new force (M3)

really i'm in pain, thanks.

ciao faccie da sedere!
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 21st Jun 2010 17:16
(x1, y1, z1) + (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)

You can either divide the vector components


or you can use DBP's built in commands:


Euler angles require a bit of a different approach. But I'm guessing you meant the vector components when you said angles.

Cheers!
Sven B

Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 21st Jun 2010 18:42 Edited at: 21st Jun 2010 18:44
no, it isn't this. thanks for your time anyway

i know is my fault i've a poor english, but i try in another way:

i've a ship moving in the space, z angle is disabled, always 0.
now it is bearing x1=object angle x,y1=object angle y.
it is moving at a speed of m1,for example "5.0" (every sync move object ship,m1)

now it collides with an asteroid, the asteroid moves with an angle x2=object angle x,y2=object angle Y (of the asteroid)
its speed is m2,for example "2.0" (every sync move object asteroid,m2)

now, the ship will alter its speed and direction, how i do this?
i have two vectors with two forces (x1,y1,0 angle of the first vector and m1 its force,x2,y2,0 angle of the second vector and m2 its force), how combine it?
when i was at school,someone teach me how to do this in 2d, but not in 3d and i forgot about this.

ciao faccie da sedere!
Robert The Robot
19
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 21st Jun 2010 19:16 Edited at: 21st Jun 2010 19:18
Surely if Z angle is 0, then there can be no movement on the z-axis, hence it is still just 2D?

Rather than using force and (x,y1,0) angles, maybe it would help if you resolved the force into its components (i,j,k in unit vectors)

http://hyperphysics.phy-astr.gsu.edu/hbase/vect.html#vec5
This link shows how to solve it for 2D, 3D might be a little more tricky but I think it is like the x-axis:

(Pythagoras still works in 3D, d = SQRT(x^2 + y^2 + z^2) )

Now when you want the change in ship's velocity, you can make it anything you like as long momentum (mass x velocity) is conserved on each axis (x,y,z).

Hope this helps!

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 21st Jun 2010 19:52
nope... is not that, you make it easy... z axis is useless in this case.
2d movement around x and z , i need only 1 angle.
3d movement, i need 2 angles, y for x and z axis and x angle for angle on y axis.
now, it isn't difficult to think,the ship's position s ininfluent, just think a point in a 3d space,this point has a direction, a x angle and a y angle, yes it has even a z angle, but is always 0.
this point has a speed,moving the object in the direction of "rotate object ship,x,y,z"
now, the ship start looking in another direction, and try to move in the new direction.
But it is in the space,we have inertia here,so,the first time the object try to move in the new direction, starting its 'engines' the object will not move exactly in the new direction, but the direction will be the result of the old direction and the old speed with the new direction and the new speed.
This is 3d math, ergo we have a first vector, the old speed and is an angle x,y,z and a force, the new vector with its angle on x,y,z and its forcce.
we will have a third vector the result of the previous two vectors.
it's for a space game, it's inertia in 3d space.

ciao faccie da sedere!
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jun 2010 01:25
Sounds like you want "curve angle" or "curve value". (i can't recall what the exact DB command is)
Basically what this will do is interpolate between the old and new value, giving you a gradual change towards your new direction.


"Any sufficiently advanced technology is indistinguishable from magic" ~ Arthur C. Clarke
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Jun 2010 02:46
Ermes

You seem to have confused "vectors" with "angles" (and possibly momentum?). They are quite different. If you want to add vectors - well, just add them using
add vector2 or add vector3, etc, as Sven B said
whichever is more appropriate.

Express your problem in terms of vectors alone and you'll be more than halfway to solving your problem yourself.

I don't think there is any important difference between 2D and 3D as far as vector resolution of forces, directions and momentum are concerned - you just have 2 numbers in one case and 3 in the other.
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 22nd Jun 2010 13:10
no... i want to add two vectors with their angles and momentum, not positions, maybe "VECTORS" is not the right word, "VECTORS" not of dbpro, "VECTORS" of physics.



ciao faccie da sedere!
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 22nd Jun 2010 20:12 Edited at: 22nd Jun 2010 20:22
I don't know why you wouldn't just store actual vectors for each object. They aren't hard to obtain with the move object command. You're going to have to convert your angles and momentum into standard vectors, add them together, and then extract angles out of the new vector. All of that seems a very unnecessarily complicated process.

First, to avoid having to get into lots of math, I'm going to assume you have an object to allow DBPro to help us. AngleX and AngleY are the two angles around the X and Y axis, and Magnitude is the "momentum".

We can convert the angles and magnitude into a standard vector like this:


Use that bit of code to convert the other set of angles too. Once we have vector 1 and 2 filled with the appropriate data, just use the vector addition commands SvenB pointed out.

Add them like this:


Or, if you want to keep the old vector, just make a new one beforehand.

After that, you should have your resultant vector, just the way you want it. If you realllly want to return it to the form of AngleX,AngleY,Magnitude, you could do this:



Edit: Oh, and I'm sure that most of the confusion generated by this thread is due to the fact that two angles and a magnitude is not an acceptable way to denote a "vector". Gimbal lock prevents each combination of angles from being unique.

Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Jun 2010 21:52
Quote: "Edit: Oh, and I'm sure that most of the confusion generated by this thread is due to the fact that two angles and a magnitude is not an acceptable way to denote a "vector". Gimbal lock prevents each combination of angles from being unique."


The gimbal lock only occurs when using for example Euler angles. He's using sphere coordinates, where this problem doesn't pose itself.

But I have to agree with Kira on this one. 2 angles and a magnitude is not the way to define vectors in this type of game. You're better off storing all 3 components.

Cheers!
Sven B

Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 22nd Jun 2010 22:42
3D coordinates +3D vector(direction) means you need 2 vectors for the object. The "momentum" can be achieved by not normalizing the direction vector. When the object encounters another you need to calculate a "reflection" vector(direction). If you really want to get technical, you can add in energy conservation to your equations to cause each object to "bounce" off one another and loose a small amount of energy each time.

You don't need to do any angles to achieve this. It's all about vector/matrix math. There are plenty of math examples on the web and even in the DBP help (well, some in DBP help).

I can answer specific questions about vector/matrix math if you like......

The fastest code is the code never written.
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 23rd Jun 2010 00:37
thanks to all but we are talking two different languages, i'm sorry i can't explain in another way. sorry...

again: position of object isn't rilevant.

first point. i've a momentum with 3 angles in a 3d space.
momentum 1 has anglex,y and z. i don't need to know where is positioned in space.momentum 1 has its power, force,value, whatever it means the speed of the momentum.

second point. at momentum 1 i apply another momentum who cange the direction and the force of the momentum, resulting in a modified angle x,y,z and force of the momentum.(just think a brief engine ignition)

i guess it can be like this in my mind:



no position in the space. only angles.
i can do this in a 2d space, with some sin and cos, but not in 3d space.

i know it's more complicated of this. thanks.

ciao faccie da sedere!
Kira Vakaan
17
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 23rd Jun 2010 00:42 Edited at: 23rd Jun 2010 00:45
Quote: "He's using sphere coordinates, where this problem doesn't pose itself"


@SvenB: I dunno about that, it really seems to me that he's using euler angles. I think he's describing euler angles below.

Quote: "i need 2 angles, y for x and z axis and x angle for angle on y axis"


Hawkblood is right. You'll need to calculate the reflection vector to correctly simulate the collision. Actually, you really should take the mass of the objects into account to make it more realistic. A gigantic spaceship shouldn't veer off course when it gets hit by a pebble.

Edit: I didn't see your post there. It really isn't more complicated than that. The solutions we've given you don't have anything to do with position either. The components of the vectors we calculated are all given in reference to the object's position, wherever that may be.

Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 23rd Jun 2010 01:00
uhm maybe i've understand, now i try it!

ciao faccie da sedere!
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 23rd Jun 2010 01:21 Edited at: 23rd Jun 2010 09:39
working! thanks!

i didn't understand how vector3 is vorking. 0,0,0 to a point in the spaxe x,y,z is the coords defining the vector.
that's is the difference, i was defining the vector3 with angles... like at school...

now its all clear! Thanks!!!!!!!!

ciao faccie da sedere!
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 23rd Jun 2010 14:21
Quote: "@SvenB: I dunno about that, it really seems to me that he's using euler angles. I think he's describing euler angles below."


Quote: "i need 2 angles, y for x and z axis and x angle for angle on y axis"


Don't Euler angles have 3 angles?
If you have 2 angles and a magnitude then you can find unique values (of course, without looking at the +-2*pi for the angles).

Cheers!
Sven B

Login to post a reply

Server time is: 2026-07-25 08:13:38
Your offset time is: 2026-07-25 08:13:38