- Home /
Why in Unity is no separate Point and Vector class ?
I have wondered why in Unity no separate Point class ...
Sometimes quite difficult to figure out mistake where I have put a point as a vector and a vector as a point. A separate Point class would fix this and I would see a mistake at compile time.
Is there any updates or thoughts about it ?
I'm not quite sure how you're using the word "vector" here, but I suspect that you're using it to mean "vector used to represent a translation ".
The Vector classes are basically just ordered arrays of floats, which you can use to represent points, translations, directions, rotations, or any number of other things. It wouldn't make a lot of sense to have differently-named simple types that have the same functionality.
The way to avoid the kind of problems you're talking about, I$$anonymous$$HO, is simply to make sure you name your variables in an informative way. If vectors being used to represent positions always have "position" in their name, if vectors being used to represent directions always have "direction" in their name, and so on, then you're unlikely to make the mistakes you describe.
This question doesn't make sense. a point is a 2 vector dimension, and a Vector3 is a 3 Vector dimension, so it is just a Vector2, Vector3, or Vector4. Each of which are just comprised of Floating Point Numbers. Remembering your variables should be irreverent to what Unity does, and distinguishing between them would your IDEs and your job.
you mean the mixup you sometimes get when z is ignored for e.g. the UI, right? And with points you mean Vector2? I think they could do that, but it would not quite fit the meaning. Unity is a 3D engine, if you do a 2D game or not, doesn't matter. And everything is based on Vector arithmetics (magnitude, dot- / cross product, etc.).
A point would suggest we're talking about 2D/ pixels, which is not the case because it's all relative to Camera vs. object distance etc. and keeping everything Vectors(2,3,4) is actually cleaner than Point, Vector3, Vector4
Guys,
I mean geometrical point and vector. Both of them has three or two coordinate ((x, y) or (x, y, z)), but it is a different type of geometrical objects. Subtraction of two points will give a vector (geometrical), but they don't have multiplication operation.
If you make 2D Game -> Point2 Vector2, but if 3D -> Point3 and Vector3
What do you mean? There is zero difference between a point and a vector. You can't multiply a dimensional vector by another dimensional vector but you can multiply any dimensions of vector by a floating point number.
@redradist You're just talking about two slightly different ways of using the vector classes. They really are not fundamentally different concepts, in both cases what you're dealing with is (mathematically speaking) a vector.
Note that what you're calling a "Point" is just the same thing as what you're calling a "Vector" but relative to the origin.
Answer by jdean300 · Feb 12, 2017 at 10:22 PM
While there is a difference in the geometric definition of Point and Vector, it should not be of consequence. I have never seen a game engine that separates the two. The few times you may be confused by the difference is easily solved by reading the API/documentation or having proper variable naming. If a game engine did separate the two, I believe that would introduce more possibilities of bugs than by having the two merged. Also, the number of conversions that would have to take place between the two could become a performance problem in low level code.
It is simply far more convenient to work with them as if they were the same thing. Even in mathematics we tend to ignore the difference simply because it almost never matters.
Your answer
![](https://koobas.hobune.stream/wayback/20220612110921im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Find a point between 2 vectors for a specific Y 1 Answer
Rotation of object placed in the middle point between two points? 0 Answers
get the point directly above the raycast collision? 1 Answer
Find a Position on the Axis of a GameObject 1 Answer
Math Question : How to Get a Point on a Ray which is EXACTLY 5 units away from Vector3.Zero? 5 Answers