Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by alvaro

  1. I just want to point out that you don't need to use angles for this (or for pretty much anything else). Assuming you are using quaternions to represent attitudes, you can compute the rotation that would bring your current attitude to your desired attitude with one division. The logarithm of this quaternion will give you the angular velocity that you would have to apply for one unit of time to get where you want. That's the P term in your PID controller. The D term is your current angular velocity. I can think of a couple of ways of implementing the I term, but you can start without it and think about it later. I can put together some sample code for this PID controller if you are having a hard time. Just ask. There is also a dynamic-programming approach to optimal control theory which would be interesting to apply to this problem, but that's more involved.
  2. Figuring out the angular impulse to reach some target orientation is the angular equivalent of figuring out the linear impulse to reach some target position. It basically makes no sense. You have to decide how quickly you want to get there, as pcmaster pointed out.
  3. alvaro

    Quaternions, how does ki = j?

    You still haven't given me the list of axioms you are starting with, and without that I can't even start to help you.
  4. alvaro

    Quaternions, how does ki = j?

    I've always thought of quaternions with all those identities to begin with, but there's probably a shorter list of properties from which all of these can be deduced. I imagine that's what you are trying to do. That's why I was asking what axioms you are starting from.
  5. While you are at it, instead of vague descriptions of the results you are getting, post pictures of what you get and --to the extent you can-- what you would like to get.
  6. alvaro

    Quaternions, how does ki = j?

    I'm not sure what axioms you are assuming in your computations. In other words, I don't know which known identities you are using to try to deduce other things. To me the basic identities are: i2 = j2 = k2 = -1 ij = -ji = k jk = -kj = i ki = -ik = j You can easily compute anything with those. You seem to start with ijk=-1, which is true, but I had to do (ij)k = k2 = -1 in my head to verify it. To go from j(ijk) to -ij2k, I simply swap the order of the first "ji" to "ij", which makes the sign flip: j(ijk) = (ji)jk = -(ij)jk = -ij2k Alternatively, just compute both sides and verify they are -j.
  7. alvaro

    "Nice" tweakable S-function

    Try this: 1/(1+exp(-s*(-log(1/x-1)))) s=1 is the identity. As s grows, the function converges to the step function, as you wanted. Values of s between 0 and 1 are also possible, and behave reasonably. EDIT: Oh, I think my function is actually the same as x^s/(x^s+(1-x)^s), which is what Zakwayda pointed to: http://www.wolframalpha.com/input/?i=simplify+1%2F(1%2Bexp(s*ln(1%2Fx-1)))-x^s%2F(x^s%2B(1-x)^s),+assuming+s>1+and+0<x<1
  8. He did post this information, and it is 8bpp: m_pDevice->CreateTexture(64, 64, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &sightTexture, NULL);
  9. I don't see enough code here. How many bytes per pixel are you using?
  10. alvaro

    Bi-coloring mathematical programming problem

    This is easy? I am very good at this kind of thing and I didn't think it was all that easy. I mean, I knew how to approach it right away because I am familiar with the much-harder problem of counting legal positions in go. But if I hadn't know that, I think I would have had a hard time. Did you notice n can be up to 1000?
  11. alvaro

    Bi-coloring mathematical programming problem

    Fun with polynomials! If n=3 and k=4, compute the following polynomial: https://www.wolframalpha.com/input/?i=Expand+[[1,1,1,1]]+*+[[1,1,1,x],[x,1,x^2,x],[x,x^2,1,x],[x,1,1,1]]^(3-1)+*+[[x],[x^2],[x^2],[x]] The coefficient of x^4 is the answer. Actually, I can't think of any other way to solve this problem.
  12. alvaro

    Bi-coloring mathematical programming problem

    There is a definition of "component" in the link you gave us. It's some sort of inductive definition, and those are hard to get used to. In this case, the definition might not even be correct. There are other ways to define the same concept. Two cells are in the same component if and only if you can reach from one to the other stepping only between neighbors. EDIT: That was an interesting problem. Too bad the link is now broken. Is it available anywhere else?
  13. The cross product of (1,0,0) and (0,1,0) is (0,0,1) no matter what handedness you are using. Handedness only enters when you assign (1,0,0) the meaning of "to the right of the screen", (0,1,0) the meaning of "upwards along the screen" and (0,0,1) the meaning of "perpendicular to the screen away from the viewer", for example. Now in order to determine the sign of rotations and the sign of the cross product you can use a hand, and you'll find out whether this is a left-handed system or a right-handed system.
  14. What makes the system left-handed is your interpretation of what the x, y, and z coordinates mean when you visualize the vectors. The arithmetic is independent of handedness, so there is nothing in the library that depends on it.
  15. Oh, the way I think about it I would say that B has a virtual destructor even if you didn't write one. So I believe we agree.
  16. The sentence you were responding to was this: That is exactly right, except he might have missed the word "from" that I added in square brackets. If you write a class that is intended to be used as a base class and you don't declare its destructor virtual, a derived class that has non-trivial work to do during destruction may not get its destructor called when a pointer to base is deleted. Was this just a language issue, or do we disagree on something? I am not sure...
  17. Can you post some code? For instance, I fail to reproduce the problem with this: #include <iostream> struct X { virtual ~X() { std::cout << "Start ~X\n"; } }; struct Y : X { ~Y() override { std::cout << "Start ~Y\n"; } }; int main() { X *x = new Y(); delete x; }
  18. alvaro

    Programming and Higher Mathematics

    Googleology will only get you so far. If you know linear algebra really well, you'll recognize vectors and linear mappings everywhere. If you don't know linear algebra really well, it might not occur to you that an audio signal is a vector, that the dot product can be used to define an angle between audio signals, which gives you a measure of similarity, or that the total energy of an audio signal is precisely the square of the length of the vector. Or that the definition of correlation in statistics is suspiciously similar to the definition of cosine in geometry; realizing this enables you to leverage your intuitions of geometry for statistics, or it can help you think of high-dimensional geometry using the intuitions from statistics. Just like geometry, signal processing and statistics, programming is another discipline in this same universe of related fields, and a programmer that knows nothing about the other fields and how to draw connections between them will always be a second-rank programmer.
  19. My understanding of behavior trees is that you define a whole bunch of functions in your game code that return a boolean. These can be functions that get information about the situation (Is there an enemy nearby? Do I have ammo? Is my health above 60%?) or functions that actually do something and return whether they succeeded (Move to take cover. Shoot at the weakest enemy within range. Say "Halt!"). A behavior tree is then an expression that joins these functions with the equivalent of the operators || and && from C. The strength of this paradigm is that it's impossible for the game designer to go crazy with the complexity of the behaviors. If you need to define a whole bunch of variables in a blackboard, perhaps this very simple architecture is not a good fit for your task.
  20. If you think those algorithms "don't work perfect", you must have some idea in mind of what you want them to do. Since you are not giving us any details or examples of what you want, we are likely to produce algorithms with the same problems than the ones you are finding on the web. You've been around these forums long enough that you should know how to ask questions by now.
  21. It can be made as accurate as needed. If I remember correctly, there is a factor of O(log(1/epsilon)) in computation time if you require errors of order epsilon.
  22. I completely disagree. The fact that you can't make everybody happy doesn't mean that you shouldn't try to make anybody happy. Names should be picked so they facilitate the process of reading the code. The person reading the code could be you in a few months, so try to make life easier for yourself by using good names.
  23. There is an algorithm called the fast multipole method, which can do this much much faster (it's at least O(n*log(n)), and perhaps even O(n)), but it's tremendously complicated. At some point I understood most of it, but at the time I was only interested in a 1D version of this problem. Maybe I'll give the 3D case a try someday, since it could make for a really cool demo with maybe 1 million particles.
  24. Updating the OP makes it difficult to follow the conversation, so please don't do that. You can just post updated code in another message. Even in the single-threaded scenario, it's probably wrong to update the particle positions as you go. Anyway, I suggest you start with 2 particles, then 3 and see if you can follow the calculations by hand. If you have the working version of the code somewhere else, you can make both versions spit out details of what they are doing so you can track where they diverge. Debugging is an important skill to develop, and this is a good opportunity to do so. Good luck.
  25. I don't have a solution to your problem, but I see a few opportunities for improving your code. pointsx[i] += velx[i] -= fx; pointsy[i] += vely[i] -= fy; That's hard to read. Try to make life easy for the reader. You don't need Math.sqrt() to check if a distance is greater than 1: Just check if the distance squared is greater than 1. You shouldn't use goto where a more descriptive control-flow mechanism exists. In this case it's just a do-while loop. You are mixing the computation of the updated positions and velocities with the details of the representation (aspect, zoom). That is poor taste. A function that is called Compute should not be in the business of doing any part of the rendering, and it should not know anything about how the positions will be mapped to a screen. Oh, maybe I found it: You are updating positions and velocities as part of the parallelized loop, while other threads might be reading from it. There's no guarantee if the other threads are going to read the positions before the update or after the update, or even if they are going to read a valid position at all (maybe they'll get the old x but the new y?). You need to store the new positions and velocities in a separate array and do the updating once the parallelized loop is over.
  • 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!