
Advertisement

Content Count
7978 
Joined

Last visited

Days Won
4
Content Type
Profiles
Articles and Tutorials
News
Contractors
Columns
Podcasts
Games Industry Event Coverage
Gallery
Forums
Calendar
Blogs
Store
GameDev Links
Projects
Developers
Everything posted by alvaro

Calculate the amount of torque impulse needed to get to a certain orientation.
alvaro replied to Axiverse's topic in Math and Physics
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 dynamicprogramming approach to optimal control theory which would be interesting to apply to this problem, but that's more involved. 
Calculate the amount of torque impulse needed to get to a certain orientation.
alvaro replied to Axiverse's topic in Math and Physics
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. 
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.

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.

In game image memset function not working...
alvaro replied to rjhwinner03's topic in General and Gameplay Programming
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. 
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.

Try this: 1/(1+exp(s*(log(1/x1)))) 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+(1x)^s), which is what Zakwayda pointed to: http://www.wolframalpha.com/input/?i=simplify+1%2F(1%2Bexp(s*ln(1%2Fx1)))x^s%2F(x^s%2B(1x)^s),+assuming+s>1+and+0<x<1

In game image memset function not working...
alvaro replied to rjhwinner03's topic in General and Gameplay Programming
He did post this information, and it is 8bpp: m_pDevice>CreateTexture(64, 64, 1, D3DUSAGE_DYNAMIC, D3DFMT_L8, D3DPOOL_DEFAULT, &sightTexture, NULL); 
In game image memset function not working...
alvaro replied to rjhwinner03's topic in General and Gameplay Programming
I don't see enough code here. How many bytes per pixel are you using? 
Bicoloring mathematical programming problem
alvaro replied to gamelearner's topic in Math and Physics
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 muchharder 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? 
Bicoloring mathematical programming problem
alvaro replied to gamelearner's topic in Math and Physics
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]]^(31)+*+[[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. 
Bicoloring mathematical programming problem
alvaro replied to gamelearner's topic in Math and Physics
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? 
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 lefthanded system or a righthanded system.

What makes the system lefthanded 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.

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.

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 nontrivial 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...

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; }

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 highdimensional 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 secondrank programmer.

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.

how to generate all combinations of certain alphabets with repeat and without repeat
alvaro replied to moeen k's topic in General and Gameplay Programming
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. 
nbody physics wrong after separating interleaved xy coordinates
alvaro replied to CommanderLake's topic in Math and Physics
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. 
Good name for this meta programming class ?
alvaro replied to Alundra's topic in General and Gameplay Programming
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. 
nbody physics wrong after separating interleaved xy coordinates
alvaro replied to CommanderLake's topic in Math and Physics
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. 
nbody physics wrong after separating interleaved xy coordinates
alvaro replied to CommanderLake's topic in Math and Physics
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 singlethreaded 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. 
nbody physics wrong after separating interleaved xy coordinates
alvaro replied to CommanderLake's topic in Math and Physics
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 controlflow mechanism exists. In this case it's just a dowhile 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