Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by redradist · Feb 12, 2017 at 05:51 PM · vector3point

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 ?

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bonfire-Boy · Feb 12, 2017 at 06:11 PM 0
Share

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.

avatar image RobAnthem · Feb 12, 2017 at 06:14 PM 0
Share

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.

avatar image hexagonius · Feb 12, 2017 at 06:22 PM 0
Share

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

avatar image redradist · Feb 12, 2017 at 07:42 PM 0
Share

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

avatar image RobAnthem redradist · Feb 12, 2017 at 07:52 PM 0
Share

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.

avatar image Bonfire-Boy redradist · Feb 12, 2017 at 07:59 PM 0
Share

@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.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges