246: GameDev: Points Vs. Vectors. Which Should You Use?

Take Up Code - Un pódcast de Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categorías:

Do you know the differences between points and vectors? You might be surprised. I learned a few things myself recently when I implemented points and vectors in the TUCUT library. Listen to episode 240 to learn more about TUCUT. As to which you should use, that’s sort of a trick question. You’ll most likely use whatever your game engine provides. Unless you’re writing your own library like I’m doing, the idea of a point and a vector are very basic concepts that would be provided for you. Any type of drawing needs to know where to do the drawing. Animations need to know which directions to move. Game items need to know where they exist in the world. Listen to the full episode to learn what you can do with points and vectors, how they can interact, and why many game engines provide only vectors. You can also read the full transcript below. Transcript You might be surprised. I learned a few things myself recently when I implemented points and vectors in the TUCUT library. Listen to episode 240 to learn more about TUCUT. As to which you should use, that’s sort of a trick question. You’ll most likely use whatever your game engine provides. Unless you’re writing your own library like I’m doing, the idea of a point and a vector are very basic concepts that would be provided for you. Any type of drawing needs to know where to do the drawing. Animations need to know which directions to move. Game items need to know where they exist in the world. And because game engines provide these features, they need a way for you to specify points and vectors. Traditionally, points have been mostly a geometry topic and vectors an algebra topic. I see them as very close concepts and the differences between them can sometimes be a matter of preference. One of the strange things I found in my research was the idea that points have no coordinates. They exist at some location and the reason they have no coordinates is because there could be multiple coordinates that end up in the same location. For example, if you have a sphere like earth and a point is some city. Then you can pick an origin and go to the city. But you can also keep going and come all the way around the sphere until you reach the same city again. Depending on how your points exist in the universe, they might have many different coordinates. Or maybe you have multiple origins or an origin that moves around. This would cause the coordinates to change. Think of it like this, if you live near the border of a city and the city border changes, then you might get a new mailing address. It’s not like your house suddenly changed its location. But the origin changed and now your address is relative to a different city or county. Or maybe you have different ways of measuring distance. It could be millimeters or inches. The same point will have different coordinates if you use different measurement systems. To me, these are not good reasons for saying that points have no coordinates. I’m okay with the idea that coordinates need to be matched with a specific origin and measurement system. If the origin changes, then the coordinates will change. And if there’s different ways to get to the same point, then to me that’s okay too. A vector is more flexible in this sense. Because vectors have no origin. Let’s take an example in a single dimension. Imagine a point at coordinate 8 and another point at 10. A vector will tell you how to get from 8 to 10. Just move two unit positions to the right. That’s all a vector is. Just a magnitude and a direction. In this example, the magnitude is 2 and the direction is towards the right. What if you want to go from point 5 to point 7? You get the same vector, two units to the right. Now, the points themselves are based on the origin. So you get to a point at position 5 by starting at the origin and moving five units to the right. This is where the differences between points and vectors

Visit the podcast's native language site