Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

294 Neutral

About ryt

  • Rank

Personal Information

  • Interests
  1. Ok, I plotted every function. I can see where you were going with this through I don't understand it yet completely. Maybe I'll get to it later. @swiftcoder mentioned that you are using mod() to wrap the function back to desired range but you were not converting it to radians in the first place so I'm left a bit confused. I see that you had to bring it back because of +2 (+M*.5) but it's still not entirely clear to me. It came to my mind that when I tried to convert [0, 4] to [0, 6.28] radians I can do it with percentages too. If we say that the first part is in domain K and second in domain L, then if we have some angle A_k in domain K, we can divide it by K Lenght, that is 4. This will give us the percentage p. If we multiply L Lenght * p it will give us the same angle in domain L, that is a angle A_l in radians. Now, I know that the next calculation is wrong, but I guess that we could do something like we did before to get the same answer, try to multiply A_k * 6.28 and mod() this with K/L Lenght. This doesn't give us A_l but I'm sure that we could do something similar to arrive to it?
  2. I feel like I'm so close to understand this but somehow I'm not quite there. Could you please explain this a bit further, why do we use modulo here (@alvaro solution) for the expected value? How does that returns us to the desired range? Edit: Oh, I think I see, we just scratch the extra value, the value that got us to 8pi (4 times around the circle). Now it looks like to me that it's mandatory to use modulo after a multiplication so we could get back to transformed space, is this true?
  3. Thanks for the code snippet. Though I must say I don't understand it very well. I see that A is current location, B is the desired, M is probably the length of the circle and abs(A - B) is the distance, but I don't see why we have to add + M * .5 and that two times (second time with subtraction), use mod() and than again abs()? How I originally thought to solve the problem is to first transform it to radian space. I thought to multiply my domain x[0, 4] like x * 2pi. This would get me to [0, 25.12] which is I think not what I wanted. I think I should somehow convert [0, 4] to [0, 6.28] if I'm correct and than I'll be able to use sin(), cos() to get the distances and other things?
  4. Let's say we have another circle but this time not in radians but instead in domain [0, 4], where 0 represents beginning (like 0 rad) and 4 represents the end (like 6.28 rad), 0 and 4 are same point and 1, 2, 3 are evenly spaced between them (that is pi/2 apart). Than let's say that there are two points A and B on this circle. B is a fixed point and A tries to reach it through the shortest distance. Let's say that B = 4 and A = 3. Can we use the math we used above to find this solution for any points A and B? Would it help us if we transform this space to radians and than try to solve it? I invented this problem to see if I could apply the above logic. Maybe I went a bit of the path and the problem doesn't really need all the logic or it could really need something different. I'm not sure at this point so I wrote it.
  5. I'm confused about this one, I guess you meant to write 2pi*x = 1 or similar. Edit: Oh, I think I got it. To rewrite you meant T seconds * (1/2pi) = R radians which yields 2pi = T/R. From your first equation, T seconds * x = R radinas, if I'm correct we can conclude that multiplying some dimension (seconds here) by a constant gives us another dimension (radians in this case). I think that we get as a result radians because we explicitly multiplied with 2pi (could be pi too), but if we chose to multiply by some other constant we would get some other arbitrary space, not necessarily in radians? For e.g. multiplying by 0.01 would give us a percentage, or multiplying by some other constant would give us some other space.
  6. I came with two examples. Lets say we have to numbers, t = 3 and t = 15. These could be interpreted as times with dimension in sec. For first part, if we multiply 3 * 2pi, we get 18.84. Since pi is in radians we get 18.84 rad. This could be thought of changing the space and getting it actually in radians, something like in 3 sec we passed over 18.84 rad. For second part, if we divide 15 / 2pi, we get 2.38. Same as before this is 1/rad or if we think of t as time than it becomes sec/rad. This can be thought of how many units per some other unit, or how many sec per one rad, something like 2.38 sec in 1 rad. Another example that comes to my mind is taking a t between [-1, 1] that goes back and forth. If we multiply t * 2pi, we are getting a space in rad that corresponds to rotations [-6.28, 6.28] that go also back and forth. A rotating circle that rotates one turn in each direction. Taking the same example and dividing it instead t / 2pi, would get us [-0.15, 0.15] which would mean 0.15 in each direction per one rad.
  7. Do you maybe know some examples where we would want to multiply by 2*pi and where we would want to divide by 2*pi? What would be the effect of only using only pi instead of 2*pi? I know that the resulting value would be smaller for multiplication case and with your explanation that 1 unit would represent half rotation but I'm just asking for completeness in case I forgot something.
  8. I guess that that's true. I wanted to transform for e.g. time variable to rotations and see what I will get. By your explanation I think that the important thing to remember is that 1 unit, that is if we multiply there is a one-to-one relation between 1 and 2*pi, from the e.g. 3sec will be translated to 6*pi (3 rotations). On the other hand if we divide, one unit (a span) is transformed to 0-2pi so a dividend "falls" into this space. I hope I got that right, I know it's a bit confusing.
  9. Lets say I have some variable x in a domain i.e. <-inf, inf>. If I want to change it's space I know that I can multiply or divide it by some other number k, i.e. if I want to change it to circular space I can multiply/divide it by 2PI. What is the difference if I multiply it versus if I divide it by some number, what would be the outcome and what are the different uses? I could take for e.g. time variable t and multiply/divide it by 2PI. Why would I want to do one versus the other besides that one gives smaller resulting values and other one greater values?
  10. Thanks, nice explanation. In DirectXMath since it's a row-major representation, as you mentioned, the yellow part is x^ basis vector _11, _12, _13, but if I'm correct the right vector would be _11, _21, _31 as explained in the link.
  11. ryt

    Weird behavior in my collision

    Yes that's it. That's why the object is wobbling when is in another object. Because collision fires each time and every time it changes its direction by -dir. I'll try to implement one of these methods you mentioned. Thanks.
  12. I implemented a simple AABB and Circle collision system in my engine. It mostly works ok but sometimes I get really weird effects. When a Circle touches (collides) AABB, sometimes it doesn't bounce right away but it enters into the box. It's barely noticeable and when it enters ti doesn't automaticaly go out but it wiggles for bit and after 1-5s it exists in correct direction. This is my code to change direction after Circle collided with AABB (collision returned true): if (psprite->Tag() == TagType::WALL_LEFT) { dir = Vector2(-dir.x, dir.y); } Where psprite is a Wall sprite and this code is located in Ball class (Circle collider). Have you encountered something similar? I just can't figure what's wrong.
  13. Wow, thanks, really interesting to code this way. I found another way too. I removed the global pointer to Input, added a pointer to itself that's inside the class, like Input::Input *_pInput and moved public methods to static ones. Now whenever I want to access this global class I just access its public static methods like Input::OnMouseMove() and this method does appropriate logic through *_pInput. I just initialize the class in main() so I can get this pointer and any outside classes don't know anything about this pointer, they just use static methods.
  14. Thanks, that's what I was looking for. You were right, Game/Engine class is an instance created in main entry point. Another question, as I've been recently coding with Unity3D, I saw that they use an "global" Input class that can be called from I think almost everywhere, like it's static or global in some kind. How come that they didn't went with the approach of passing it manually or through dependency injection to other classes? Or I misunderstood something?
  15. In my game engine that I'm writing I have a Engine class that connects to Allegro library and handles intermediary things like game loop, update, render and events. Specifically to handle input and it's events (from Engine class) I created Input class. This class is instantiated using a global pointer (which I know is... bad) which is passed to Engine class, so that engine could connect it with Allegro. I wanted to create Input class to be as much independent and modular so I inherited it from IInput interface. Engine class knows only about this IInput so that in future I could switch Input class with some other class from IInput. My question is how I could remove this global pointer of Input class? I thought of converting Input to an static class, but than I can't get a pointer to it which I need as a param to Engine class (through IInput). I also thought of making Input a singleton but I'd rather not do that. The final goal I had in mind is to have multiple classes that are completely independent of each other and inherited of various interfaces, like IInput, IAi and ISomethingElse, so that in future I can replace Input, AI with some other implementations of same interface.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!