![]() I've worked with systems using both approaches and found it's only sane to seperate them in large scale, math heavy projects. Probably I am just too drilled by writing ray tracers, where the mathematical model is often common ) Thanks to that distinction and the thorough constraints upon Points (operator+, operator-, distance), only the most basic fixed point math is needed (addition, subtraction, comparison). I need this so that I can use fixed-point arithmetic for points, but floating point math for directions. ![]() In picogen, the distinction is important for yet another reason: Points and Vectors are allowed to use different scalar types. Point+Point is not defined, Point-Point yields a Vector, PointVector yields a new Point, et cetera. using: angle of 2 relative to 1 atan2(v2.y,v2.x) - atan2(v1.y,v1. Vector direction = B-A float length = direction.length() Point newP = A + direction * 3 If we want a + or - value to indicate which vector is ahead, then we probably need to use the atan2 function (as explained on this page). To give an example of how I am used to it: Some operations are also distinct, dependent on whether the underlying concept is point, vector, or normal.Īs you see, it already confused me to see some angle between points, which only makes sense if we assume some coordinate origin to both. intentions) and less error prone (operations that don't make sense are forbidden). I think it is only beneficial to seperate those models (and comes at no extra runtime cost), as I made the experience that it makes code clearer (i.e. So in the OP's case, it's really mapping one origin vector to another and determine the angle between them. For the most part, 2D games can save on some code by having a joint "point"/"vector" class, even though it is amathematically incorrect model :D gives the angle in degrees between the vectors as measured in a counterclockwise direction from v1 to v2. This becomes a nuisance eventually, though, with "w" values. I've seen this from indies, hobbyists, and commercial shops :) Basically considering a point to be a vector originating from the origin. Returns the oriented angle between two 2d vectors Parameters need to be normalized. The vector coordinates are generated by the equation V (1. Often (and incorrectly so), points and vectors are used interchangeably in game dev, especially 2D game dev. Get a vector constructed by linearly interpolating between this vector and the given vector. The only sane measure between two points that I am aware of (at 10 in the morning) is distance. Points are dimensionless entities with no direction in any n-space. How exactly do you define "angle between points"?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |