#### Archived

This topic is now archived and is closed to further replies.

# Names of vector operations

This topic is 5851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am making a 2D game with physically accurate object movement and collisions. I managed to make it work, but I have one small problem - since using scalars, like object.x += object.vx; object.y += object.vy; was boring, I decided to create my own vector library and now I can write vector_add(&object.position, &object.velocity); I''m rewriting all my game to use vectors and now I have a problem - what names should I give to my vector functions. For example, if there is float value = a.x * b.x + a.y * b.y; in my code, then I put a vector_dot_product(&a, &b) function there. But what to do with this: float value = a.y * b.x - a.x * b.y; I want to do: float value = vector_operation_with_some name_that_other_people_can_understand_and_not_laugh_at_me(&a, &b); but does this operation have some special name? Another example: c.x = a.x * b.y + a.y * b.x; c.y = a.y * b.y - a.x * b.x; I searched the web, but found only vector sums, dot products and cross products. Are there some special names for other vector operations or should I invent my own terminology?

##### Share on other sites
quote:

c.x = a.x * b.y + a.y * b.x;
c.y = a.y * b.y - a.x * b.x;

This is called complex product, where .y is the real part and .x is the imaginary part.

quote:

float value = a.y * b.x - a.x * b.y;

This can be called something like dot_product_rotating_one_of_the_vectors_90_degrees_first, but it''s a pretty long name.
You can also think of it as evaluating a vector internal product which is not the standard dot product and whose matrix is
[0 +1]
[-1 0]

This means that you compute vector_a * M * vector_b_transposed.

##### Share on other sites
quote:
float value = a.y * b.x - a.x * b.y;

This is the z component of CrossProduct(b,a).

##### Share on other sites
Thanks for the replies. At least now I have some idea what should I search for .

##### Share on other sites
While you''re at it, look for "operator overloading", if you''re using C++. It makes vectorial operations look much nicer.

Cédric

##### Share on other sites
Just to expand what cedricl said, a little;
It makes operations like...

Vector A, B, C;
...
//Init A, B & C
...
A = B + C;
A += B;
A /= C;
C = A * B;

... possible

##### Share on other sites
And how exactly do you define division of a vector by a vector?

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

##### Share on other sites
What makes you think /= must denote division? It''s just a symbol. Use it for whatever you like.

##### Share on other sites
quote:
Original post by Anonymous Poster
What makes you think /= must denote division? It''s just a symbol. Use it for whatever you like.

No. Don''t do that. The whole point of operator overloading is to make the code clearer. Sure, you can map operator+ to the substraction of two vectors, but it defeats the purpose of operator overloading.

Cédric

##### Share on other sites
What makes you believe someone would like to use + to denote subtraction?

1. 1
2. 2
Rutin
15
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• ### Forum Statistics

• Total Topics
633270
• Total Posts
3011155
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!