• Content count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About asmcoder

  • Rank
  1. Balistics???

    Thanks a lot for all your help. I really apreciate it. And sorry about my troublesome ignorance which I should compensate by learning basic of 3D-Maths... The formula float arrowangle = atan2(yAB,xAB) worked like a charme! :) Thank you.
  2. Balistics???

    Hi, Thanks a lot for your detailled help. I realy apreciate it. Unfortunatly, the formula you provided didn't work for me, here is the code: void Update{ X+=VX*dt; Y+=VY*dt; VX+=Gravity*dt; //CALCULATE AB: int xAB= X-LastX; int yAB=Y-LastY; //CALCULATE ABS(AB) float ABSAB= sqrt((xAB*xAB) + (yAB*yAB)); //CALCULATE ACOS(ABS(AB)/xAB) ArrowAngle = acos(ABSAB / xAB); LastX=X; LastY=Y; } I still can't find a way to calculate the angle to rotate the arrow image, iam stuck and will apreciate any help to get this done. Thank you.
  3. Balistics???

    Thanks a lot for your help. So the angle I want my arrow to rotate can be calculated like so: angle = acos((abs(AB) * abs(c))) / dot(AB, c)) I believe A,B and c are stored as Vectors... abs(c) is the absolute value of c, and dot(AB,c) is the dot product of the two vectors AB and c wich can be caluclated as follows (as found on this page: float dot_product(float *a,float *b) { float dp = 0.0f; for (int i=0;i<2;i++) dp += a[i] * b[i]; return dp; } What I cannot understand is how to calculate AB? Is it A+B or A*B? Would really apreciate your help. Thanks.
  4. Balistics???

    Hi, Thanks a lot for all your help. i gave this a little go and managed to get it done. The code I used is the following: // INIT: // VX=cos(-(Angle))*Speed; // VY=sin(-(Angle))*Speed; // VX2=0; // ArrowRotation=Angle; // // UPDATE(MOVE): // // X+=VX*delta; // Y+=VY*delta; // // VX+=GravityAcceleration*delta; // // ROTATE ARROW(); // RENDER: // // DrawArrow(); Now the arrow is moving nicely and smoothly, but the problem is that the arrow image should rotate according to it's direction. (e.g: the arrow head should face the ground when falling down). How could I possibly know the angle to rotate the arrow image? I've tried a lot of random combinisations but none worked. Would apreciate your help. Thanks.
  5. Balistics???

    Thanks for the help. You've neglected the Angle in you calculs, which I believe it's the most important factor to determine the path of the projectile (Position of projectile per frames). I think the magic word here is "Arcing projectile algo" , I've found this which I think it can help: I would try to see if that works for me, meanwhile, I'll be very interested if somebody could provide me with a working way to solve this. :) Thanks.
  6. Balistics???

    Cheers for the definitions! That would help for sure. So, how am I going to implement the firing mechanisme as described on my previous post? Thanks a lot.
  7. Balistics???

    Hi! Sorry for being unclear on my previous post. I've made a little picture to describe the problem, it shows some diferent possibilities. Known prameters before the launch of the projectile are: the starting point (x0, y0), the Initial Speed or Power(S) and the Angle (A). What I want is a formula to make my projectile move (One step per frame) according to the path of the projectile. Would realy apreciate your help. Thanks. EDIT: By "velocity" in the picture, I mean "initial speed" or "Power"... Sorry, my Physic skills are poor! :(
  8. Balistics???

    Hi, Could anyone please tell me how to determine every point in a projectile path, according to the angle and the power? I am trying to implement a firing system similar to the one used on Bowmaster prelude : I have tried to google for it, I've found a lot of formulas and I cannot determine which one to use to solve the problem. Thanks. [Edited by - asmcoder on August 31, 2009 12:35:45 PM]
  9. Arctg table!

    Cheers for the explanations dude! I'm very interested on your article. Could you please point me a link to it? Thanks.
  10. Arctg table!

    I've done that using this formula: Degree=Radian*180/Pi Btw, why don't you recommend getting degree answers? Thanks a lot.
  11. Arctg table!

    I'll be using your code! Thanks.
  12. Arctg table!

    Quote:Original post by Maze Master What alvaro is saying is that you have tangent and arctangent mixed up. Arctangent takes in the ratio of sides on the triangle, which could be anything, and then returns the angle, which is between 0 and 360. It is regular tangent that takes the angle as input. Tangent:[0,360]->[-inf,inf] Arctangent:[-inf,inf]->[-90,90] So it sounds like you want tangent(x) for x from 0 to 360, right? Actually, I want something to return the angle from the diference between the point in the circle and the center of the circle. I believe this fromula applies in this case: Angle= arctangen (PointY-CenterY/PointX-CenterX) Cheers.
  13. Arctg table!

    @alvaro: I can have only 360 array's entry, and then check for the nearest array value to the value i got from calculating x-x0/y-y0. @_fastcall: Could you please provide me with the output as you did in your first post? My environement compiler does not have a math library (no cos, sin... functions) and I cannot install other compilers. Thanks.
  14. Arctg table!

    Quote:Original post by alvaro Do you mean a table with the tangent of each angle that is an integer number of degrees? I mean the Arc tangent values for the selected angle entry, so ArcTg[0] will store the ArcTg value of angle 0, and ArcTg[359] will store the ArcTg value of angle 259. See, I have a circle(x0,y0), a point in the circle(x,y). What I want to do is to detrmine the angle with this formula: Angle= ArcTg (y-y0/x-x0) so with the lookup table I can simply do this to get the angle: float Angle= ArcTgArray[(y-y0/x-x0)]; Thanks.
  15. Arctg table!

    Anyone could past here, a harcoded Arctg table as array of 360 entries? Would apreciate your help! Thanks.