Do I need a Point and a Vector object? Or just using a Vector object to represent a Point is ok?

Posted by JCM on Game Development See other posts from Game Development or by JCM
Published on 2012-11-23T18:15:20Z Indexed on 2012/11/23 23:22 UTC
Read the original article Hit count: 148

Filed under:
|
|
|

Structuring the components of an engine that I am developing along with a friend (learning purposes), I came to this doubt.

Initially we had a Point constructor, like the following:

var Point = function( x, y ) {
    this.x = x;
    this.y = y;
};

But them we started to add some Vector math to it, and them decided to rename it to Vector2d.

But now, some methods are a bit confusing (at least in my opinion), such as the following, which is used to make a line:

//before the renaming of Point to Vector2, the parameters were startingPoint and endingPoint
Geometry.Line = function( startingVector, endingVector ) {
    //...
};

I should make a specific constructor for the Point object, or there are no problems in defining a point as a vector?

I know a vector have magnitude and direction, but I see so many people using a vector to just represent the position of an object.

© Game Development or respective owner

Related posts about math

Related posts about architecture