Jump to content
• Advertisement

Public Group

# Math vector question...

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

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Is there really any need for a custom data type? By definition a vector attribute is one that has magnitude and direction... as opposed to a scalar value(only magnitude) ... So in reality int xvector; and int yvector; would be enough right? The both have a predefined direction just in their name... i know xvector is left to right and yvector is up and down. Then assign the magnitude to the variable. xvector = 5; yvector = 5; x = 0; y = 0; after move(); x = 5; y = 5; right? thanks, durfy

#### Share this post

##### Share on other sites
Advertisement
That is correct, although they would be easier to handle if you at least group them into a struct, or use a class from a library (which includes vector operations).

#### Share this post

##### Share on other sites
Ok so now:

1) take the dot product of your vector and another
2) now take the cross product
3) now transform it by a matrix
4) now normalize it
5) now scale it
6) now subtract it from another vector
7) now add it to another vector

Those are the reasons why you want a custom data type. sure setting 2 different parameters is easy but there's a whole lot of linear algebra that you perform constantly that it would be nice to have wrapped up in some overloaded operators and member functions

-me

#### Share this post

##### Share on other sites
i dont know if thats a great idea because i will mix it with the stl c++ vector
i mean i could make my own vector like class MathVector
EDIT missed this:
Quote:
 Original post by PalidineOk so now:1) take the dot product of your vector and another2) now take the cross product3) now transform it by a matrix4) now normalize it5) now scale it6) now subtract it from another vector7) now add it to another vectorThose are the reasons why you want a custom data type. sure setting 2 different parameters is easy but there's a whole lot of linear algebra that you perform constantly that it would be nice to have wrapped up in some overloaded operators and member functions

Yeah i'm not that far yet... honestly i dont know what a dot/ cross product are... Is it feasible to make my own class to handle all of these?
-durfy

#### Share this post

##### Share on other sites
If that's all you need, then that's fine.

On the other hand, if you were working in three dimensions and wanted to project a vector onto the normalized cross product of two other vectors, and then multiply its inverse by a parametric variable based on the intersection of a position vector, origin vector, and direction vector, then your notation could become a little cumbersome.

Use the right tool for the right job. If this is all you need, then that's the end of it.

#### Share this post

##### Share on other sites
is there a vector(math type) in the base c++ packaging or in the stl?
thanks,
durfy

#### Share this post

##### Share on other sites
Quote:
 Original post by Durfyi dont know if thats a great idea because i will mix it with the stl c++ vector

No you won't. The STL vector is in the std namespace. Your vector would be either in your own namespace or named something like CVector.

Quote:
 Original post by DurfyIs it feasible to make my own class to handle all of these?

Absolutely. It will help you learn linear algebra as well which is almost a necessity in game programming.

Quote:
 Original post by Durfyis there a vector(math type) in the base c++ packaging or in the stl?

Nope

-me

#### Share this post

##### Share on other sites
Quote:
 Original post by Durfyis there a vector(math type) in the base c++ packaging or in the stl?
Not really. There are plenty of free math libraries available online though. Or, you can write your own (which, as noted, will help familiarize you with basic linear algebra and programming concepts).

#### Share this post

##### Share on other sites
Thanks guys i'll create my vector class along while i read this game maths book.
Thanks,
durfy

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14
• Advertisement

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013614
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!