tbcros.blogg.se

Coords meaning
Coords meaning











Vectors are also the native representation for position, geometry, and motion used by nearly all graphics libraries-and certainly OpenGL and DirectX. When the planet moves, you change its transform, and the ship and drone automatically get positioned "for free". The planet uses its transform, the ship uses its transform and the planet's transform, and the drone uses its transform and the ship's transform and the planet's transform. With vector math, we represent each as having a point and a 3x3 transform matrix. The calculation for this without using vector math is really, really ugly. A planet has an orbiting ship, the ship has an orbiting drone.

coords meaning

If you are in 2D, perhaps the best way of achieving complex effects and motions (spinning, scaling, etc.) is to use a scene graph.

Coords meaning code#

This is very handy, and also now lets you easily have radars that point in different directions (just change the forward vector) and have different widths (just change the radar width angle)-and you can reuse the same code for those cases too!

  • Take the arccosine of that product, and check if it is less than half the angle of the width of the radar.
  • Take the dot product of the two normalized vectors.
  • Create a vector going from the center of the radar out towards the object we want to check the radar visibility of.
  • Create a vector going from the center of the radar out towards the "front of the radar".
  • Or, you could just use a dot product to do the check. You could also test if the enemies are contained in the intersection of the two half-spaces of the planes/lines defining the two side of the radar sector. You could test if the enemies are inside a triangle. So, you need to figure out what enemies are in your radar section. Every enemy that appears in the sector of the radar (some pie-shaped wedge in 2D) should get a little red dot in your screen.

    coords meaning

    Suppose you have a radar system in a top-down style game. However, the advantage to using vectors is that they neatly represent things such as direction and position, and also have several mathematical operations defined on them that make your life easier.įor a simple example of these, consider the dot product. As long as you are keeping track of x and y, or whatever coordinates you care about, in some way you are fine. While you will commonly find vectors being used for geometry in games, there is no reason you can't do something else with them.įirst, you never have to use vectors. Note that in all cases, we've assigned meaning to the vectors for our problem. Each coordinate in a vector represents some absolute position in that direction of the space the vector is in. Vectors are sets of coordinates of varying dimension.











    Coords meaning