Well in the simplest sense you have something like this.
m | \ s
o | \ p
v |(a) \ e
(y)e |angle\ e
m | \ d
e | \
n | \
t | \
The speed is however fast the enemy is, and you can determine how much they ...
In the image the red vector is the one we are trying to convert to cartesian, given angles phi & theta (in the description I will refer to the length of the vector as r, for radius of the sphere).
So, the y-coordinate is the easy one, we know what the angle is between the red vector and the y-axis (phi), we just project the vector onto the y-axis;
The edit is reassuring. :)
Okay, here's a straightforward update loop...
Assuming when we fire the missile we initialize remainingFlightTime = 5f then...
void UpdateMissile(float deltaTime)
remainingFlightTime -= deltaTime;
// At the end of the trajectory, snap to target & explode.
// The math will put us there anyway, but this saves
It sounds like what you're looking for is either a transformation matrix, or a quaternion.
I will just run down how to do this using a transformation matrix, since its probably the easier of the two to understand. A transformation matrix in 3D is a 4x4 matrix defined as follows:
H = [xx, yx, zx, tx;
xy, yy, zy, ty;
xz, yz, ...
Because on the x87 (the x86's FPU) the fsin, fcos and fsincos instructions are much faster than software CORDIC.
On other architectures such as PowerPC and ARM you usually can rely on an optimized implementation within the standard c library, the performance cost in normal use cases is still so minimal to not be worth the time re-implementing.
fsin or fcos ...
So you have two coordinates or vectors, one is the center of the screen (C from now on) and the other is your object (P from now on.)
If you know some math, you might know that a line can be expressed as an origin and a direction vector. The origin is your screen-center, while the direction vector can be found subtracting C from P. This equation can also be ...
You don't need to use any trigonometry for this. If you want the objects to be propelled straight away from the explosion, just give them a velocity proportional to the vector between the explosion point and the object's position.
Additionally, you'd probably want to make objects near the center fly faster, so one approach would be to find the vector from ...
I'm not so sure if I understood your problem right, but I'll try to answer anyways.
gluLookAt(), as its name implies, creates a view matrix for a camera, and takes three vectors as parameters.
The first one is the camera's position. This is where your camera will be located. If you want your camera to rotate around itself, you most likely don't want this ...
If you suck at maths you don't want to be starting at the game development level because game maths generally uses some advanced concepts, e.g. matrices and some calculus. Other things like vectors, trigonometry (or anything to do with angles) aren't so complex but they aren't beginner-level either.
Try Khan Academy.
Learn the basics first, then worry ...
The main reason behind the behavior you notice is that in the line motionDirection <- Math.Atan(newVector.Y / newVector.X); You set motionDirection to a radian measure, but then assume it is a degree measure on the following line. Since radian values are much smaller than degree values, this tends to just push the angle towards 0.
The main reason your ...
Depending on how often you can have a "rigged" bounce, an incremental solution might be possible.
For this example, I'll assume that:
Collisions with the playing field boundary are always normal (angle in = angle out)
Collisions with blocks can be 100% rigged whenever needed (angle out = arbitrary)
Then each time you collide with a block, check whether ...
just my impression, but are you sure that you are not over-complicating things?
Why invert the sine function at all, when you have the argument you have passed to it? That's precisely the value you are looking for, in your quest for trigonometric functions inversion...
Just either cache the sin argument somewhere before applying the function to it, or ...
Luckily this is really easy. Just take the case of one particle and one explosion.
Say the particle is at (5, 5) and the explosion is at (0, 0). Just by drawing this and looking at the picture, you can tell that the particle should move along the imaginary line between the origin and its location.
So what you need is a vector that points from the explosion ...
You might want to briefly refresh your trigonometry (maybe by reading the overview at Wikipedia) if you're stuck.
Your problem looks like this:
Keeping that picture in mind, we can take essentially the same steps you described, but in a more mathematical form:
As inputs, you have a centre point p0 (red) and an angle (blue) and a length (orange).
You are using integers for all your numbers, unless you have a very specific purpose and know what you are doing, stick to floats for geometry.
Your radius calculation is completely wrong, in createSphere you should do something like:
createCircle(posx, posy, posz + Math.cos(angle)*height/2, FOV, Points,
Set endAngle to 2π. The spacing between points in radians is your angleIncrement.
To get the Euclidean distance between two point the easiest way is calculating the distance between any two neighbouring points of the result.
Also convert endAngle and angelIncrement to float.
A common approach to this problem, and many others, is to define "attachment points" (also called "hard points" or "nodes" or a million other things) to your model/sprite definitions. These are artist-defined locations on the model such as "left foot" or "head" or such. They are usually attached to the skeleton or other animation data (each frame for ...
sqrMagnitude is the vector length squared, but you need the vector lengths. Simple fix:
return (Mathf.Acos ( scalar / Mathf.Sqrt (magnitude1 * magnitude2) ) * Mathf.Rad2Deg);
Of course you could just use Unity's angle calculation function: http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Angle.html
The other answer is wrong as of now, to correctly move along a plane based on a rotation you do the following:
posX += Math.cos(rotation) * forwardSpeed + Math.sin(rotation) * strafeSpeed;
posY -= -Math.cos(rotation) * strafeSpeed + Math.sin(rotation) * forwardSpeed;
However I'd recommend making a variable for cos/sin that you update only when the ...
You get the path the same way you'd move the object when you shoot it. Just have a tight loop that simulates the movement of the object and keep track of the position every so often. Now you have a list of positions, if you draw a dot at each position, you have a dotted line the represents the path of the object if it were to be shot from that angle.
You're only getting angles in the top-right quadrant because you're taking the absolute value of dy & dx. The sign information is important for determining what quadrant atan2 should return.
What I'd recommend instead is using vector normalization, rather than trigonometry.
dx = touch.x - startPosFrontJoystick.x;
dy = invY - startPosFrontJoystick.y;
Instead of atan(sf.y/sf.x), use atan(sf.y,sf.x). This works because it takes the sign into consideration. Dividing the two numbers loses the sign bit data, so which quadrant you are in is unknown.
You can add fragColor=vec4(pr,f,0.0,1.0); to see what is going on.
Also, if you want to fix your aspect ratio (the image stretching) add sf.y *= iResolution.y/...
you should use ShapeRenderer for this.
In your draw loop
// Draw sprites and stuff here so the line will be draw on them and not under
shapeRenderer.setColor(1, 0, 0, 1); // Red line
shapeRenderer.line(player.x, player.y, mouse.x, mouse.y);
This will let you draw a red ...
The way this is usually handled in games is something called a transformation hierarchy.
Here objects are arranged in a parent-child relationship, where each object's position, rotation, etc is specified in a local coordinate system relative to its parent's transformation. So to arrange square B so that it stays attached to the corner of square A, you'd set ...
It doesn't make a lot of sense to talk about algorithmic complexity (in the big-O sense) for the way we use atan2 in game development. Our inputs are always one fixed size (32 bit floats for the Mathf version), whereas complexity analysis looks at how the algorithm performs as the input gets arbitrarily large (not strictly in magnitude, but in how many bits ...
First of all, the FPS wouldn't be better. Most modern games are bottlenecked by the GPU mostly and are pretty OK with the CPU (often times only reaching a CPU usage of around 50% or less).
Second, CORDIC is designed to be precise and easily implementable in the hardware. The sinus method (cosinus is basically a sinus with an offset) in most languages use ...
The simple example is for rotating in xy-plane (up = z).
In order to circle around the object (at origin) at distance R, you use LookAt = 0,0,0; Position = R*cos(a),R*sin(a),0;
To rotate camera instead, the equations are LookAt = x + cos(a), y + sin(a), 0; Position = x,y,0;`
It's basically vector math, where the vector origin and target change place.