Jump to content
  • Advertisement


  • Content count

  • Joined

  • Last visited

  • Days Won


alvaro last won the day on July 9

alvaro had the most liked content!

Community Reputation

21368 Excellent


About alvaro

  • Rank

Personal Information

  • Role
  • Interests

Recent Profile Visitors

43259 profile views
  1. Yes, it's possible to find a closed-form formula for hitting a constant-velocity target with projectiles that fall due to gravity. I described the general way to approach this type of problem here. In this particular case, it's easier to use a frame of reference that falls with gravity. Then the projectiles seem to travel at constant velocity and it's the target that is accelerating upwards. Write the parametric equation that tells you where the target is at time t, and find a time t such that the distance from the origin to the target at time t is t * projectile_speed. The resulting equation is a polynomial of degree 4 in t, which can be solved in closed-form. But a numeric solver would work just fine.
  2. I No, you are probably right. But you mentioned you were getting the problem that it could align to the opposite of the desired direction, so I tried to think about it from scratch. I though we were talking about a homing missile, not a turret.
  3. The way I would do it is: Compute the quaternion that would produce the "most natural rotation" that would align your missile with the target. Look at its real coordinate to see if the rotation is larger than the limit. The real part should be at least cos(limit_angle/2). If needed, modify the quaternion so its real part is exactly cos(limit_angle/2), scaling the imaginary parts to keep the quaternion having unit length. Apply the quaternion to rotate the missile. You can find code to compute the "most natural rotation" in this thread. Depending on the genre, a more realistic Physics simulation of the missile's dynamics and a control mechanism (like a PID loop) to guide the missile could give you better results.
  4. alvaro

    Does each vector have its own basis vector?

    An affine space doesn't have an origin, correct. "Origin" is a property of the frame of reference you are using to define coordinates. affine frame of reference selection == origin selection + basis selection
  5. alvaro

    Does each vector have its own basis vector?

    Some definitions and theorems: A vector space is a set of elements we'll call vectors that can be added, subtracted and scaled. A vector space has a special vector 0, which can be added to any vector without changing it. A linear combination of some vectors is a [finite] weighted sum of those vectors. A set of vectors is said to be linearly independent if the only way to get 0 as a linear combination of them is to make all the coefficients 0. The span of a set of vectors B is the set of vectors that can be obtained as a linear combination of vectors in B. A set of vectors is called a generating set if its span is the whole vector space. A set of vectors that is both linearly independent and a generating set is said to be a basis. The number of vectors in a basis is the same for all choices of basis, and it's called the dimension of the vector space. If you have a vector space and a basis for it, you can express any vector as a linear combination of the basis vectors in a unique way. The coefficients of the linear combination are called coordinates. This allows you to do computations. In light of this, you can see that the questions in the original post don't make sense. I don't understand the first question in your second post either. I would say that "3D model space is a subspace of 3D world space" is not accurate. Model space is a 3-dimensional affine space (which I didn't define because this is getting long enough) where the vertices of the model are specified. These vertices can be mapped into the world space (another affine space) using an affine transformation. Once you have specified an origin and a basis for each affine space, an affine transformation can be described as certain 4x4 matrix.
  6. alvaro

    Get rotation angle from normalized 2D vector

    No, lack of understanding and ability to methodically analyze the situation are your problems. You'd be much better off in the long run if you took some time to understand the details. Anyway, I am done trying to help in this thread.
  7. alvaro

    Get rotation angle from normalized 2D vector

    Oh, I'm sorry. Of course, you don't have time to debug your own problem, so you expect us to help you for free. I see how that works...
  8. alvaro

    Get rotation angle from normalized 2D vector

    Try what? I don't know what values to use for x, y, player.x or player.y . Extract specific values passed to atan2 where you obtained something outside of [-pi,+pi] from it. Any additional code required will just obscure the issue, because the problem could be anywhere else.
  9. alvaro

    Get rotation angle from normalized 2D vector

    I just joined in. I gave you examples when the output is very close to -pi and very close to pi. Do you have examples when the output is *not* in the range from -pi to pi? Just a few lines of code, like I posted, would be enough.
  10. alvaro

    Get rotation angle from normalized 2D vector

    Are you saying that the range of values returned by atan2 is not -pi to pi? I don't need to make a function that rotates anything to figure that one out. I can just run this: #include <iostream> #include <cmath> int main() { std::cout << std::atan2(-1e-10, -1.0) << '\n'; std::cout << std::atan2(+1e-10, -1.0) << '\n'; } Or I can look at the documentation: http://www.cplusplus.com/reference/cmath/atan2/
  11. alvaro

    Card game AI help

    The rules of a game are often given by describing: the setup, what you do in your turn, when the game ends and how you determine who won. It's not even clear to me from the description if this is a game the OP is creating or an existing game. Once we know what we are talking about, we might be able to give you decent advice.
  12. I actually didn't read much further than that. If you want my help, you shouldn't torture me with a wall of text and stories about your difficulties staying connected to your friends. Get to the point.
  13. alvaro

    Remove VR split screen

    Can you ask the developer you are working with?
  14. The update to the velocity (using Euler integration) is typically something like this: angular_velocity = old_angular_velocity + angular_acceleration * dt You can introduce friction by this simple tweak: angular_velocity = (1 - something_smallish) * old_angular_velocity + angular_acceleration * dt That's would be my first attempt. See if that behaves the way you want.
  15. Fulcrum.013, two observations: (1) This thread is about rotation kinematics, which is not "Physically inaccurate" in any reasonable sense. It's just not full-blown mechanics, but that doesn't make it wrong. (2) Try to spell correctly. I am OK with people being a little bit careless or even ignorant of correct spelling, but it was honestly hard for me to understand what you wrote.
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!