trigonometry

Converting x/y values in camera view to pan/tilt values

Hi, I'm not very good with more advanced maths, so I have to ask this: If I have a camera which gives out 360 degree pan (x) and tilt (y) values, and I want to get the pan and tilt values of where I have my cursor in the camera's view, how would I convert that? More info: It's a Flash/AS3 project. The pan and tilt values are from the c...

Rotate normal vector onto axis plane

I have a set of data points in 3D space which apparently all fall onto a specific plane. I use PCA to compute the plane parameters. The 3rd component of PCA gives me the normal vector of the plane (weakest component). What I want to do next is to transform all the points onto said plane and look at it in 2D. My idea was to do the foll...

Sine Table Interpolation

I want to put together a SDR system that tunes initially AM, later FM etc. The system I am planning to use to do this will have a sine lookup table for Direct Digital Synthesis (DDS). In order to tune properly I expect to need to be able to precisely control the frequency of the sine wave fed to the Mixer (multiplier in this case). I ex...

Mouse pointer angle with MovieClip in AS3

Hello, How can I calculate the angle of a point the Y-axis (say, the Y position of a MovieClip) with the mouse pointer location in Actionscript 3? Many thnx! ...

How to create an "intercept missile" for a game?

I have a game I am working on that has homing missiles in it. At the moment they just turn towards their target, which produces a rather dumb looking result, with all the missiles following the target around. I want to create a more deadly flavour of missile that will aim at the where the target "will be" by the time it gets there and I...

Assembly code for sin(x)

Hi could you please give me a assembly code for calculate sin(x)[using:"Taylor Expansion"] in linux? With Best Wishes ...

Need help in getting the bouncing formula to work correctly.

I am creating a bouncing object that can bounce around a 2D rectangular room. I have read through the answer of the other question about using velocityX and velocityY instead of normal direction angle. OK, it sounds easier so I implement the following mathematical methods below. However, there is one difference. I required that I input a...

How does GraphicsPath.AddArc use the startAngle and sweepAngle parameters?

I am trying to use System.Drawing.Drawing2D.GraphicsPath.AddArc to draw an arc of an ellipse starting at 0 degrees and sweeping to 135 degrees. The issue I am running in to is that for an ellipse, the arc drawn does not match up with what I would expect. For example, the following code generates the image below. The green circles are w...

Homework: Triangle angle calculation all sides known

I know I should do my homework on my own but I simply cant get my homework to work the way I want it to: from __future__ import division import turtle import math def triangle(c,a,b,beta,gamma): turtle.forward(c) turtle.right(180+beta) turtle.forward(a) turtle.right(beta) turtle.left(beta+gamma) turtle.forward(b...

Cheap algorithm to find measure of angle between vectors

Finding the angle between two vectors is not hard using the cosine rule. However, because I am programming for a platform with very limited resources, I would like to avoid calculations such as sqrt and arccos. Even simple divide's should be limited as much as possible. Fortunately, I do not need the angle perse, but only need some valu...

Arctan > 1 newbie question

Good Day, It has been quite some time since I've had to compute the theta of an angle. But given a right angle: | | b | ----------------- a I'm trying to compute theta (the slope of the angle). My understanding of trigonometry (as rusty as it is) is that theta = arctan(b/a). So if b = 50 and a = 1811. Then using t...

How to "snap" a directional (2D) vector to a compass (N, NE, E, SE, S, SW, W, NW)?

I have a bunch of vectors normal to window surfaces in a 3D modelling software. Projected to the XY-Plane, I would like to know in which direction they are facing, translated to the 8 compass coordinates (North, North-East, East, South-East, South, South-West, West and North-West). The vectors work like this: the X axis represents Eas...

Math logic (basic trig) in a game, what is this code doing?

I'm trying to better understand what exactly this code is doing. It's written in Objective-C, but should be familiar to anyone with a C background. What exactly are sin/cos mathematics doing here? Also, does anyone have a good recommendation for learning trig for gaming concepts such as these? for (int i = 0; i < GAME_CIRCLES; i++) { p...

Get z depth from 4 vertices of a face

How can I z-order the faces of a 3d object just using the 4 vertices of each of its faces? I've tried using a z-buffer where I store the average z value of each face; this works great most of the times, but fails when an object have large and small faces. I'm building a small 3d-engine in flash, just for the fun of learning, so the only...

Calculating vertices of a rotated rectangle

Hey guys, I am trying to calculate the vertices of a rotated rectangle (2D). It's easy enough if the rectangle has not been rotated, I figured that part out. If the rectangle has been rotated, I thought of two possible ways to calculate the vertices. 1) Figure out how to transform the vertices from local/object/model space (the ones I ...

Find the normal angle of the face of a triangle in 3D, given the co-ordinated of its verticies

As you may be able to tell from this screenshot, I am trying to make a physics engine for a platformer I am working on, but I have run into a definite problem: I need to be able to find out the angle of any one of the triangles that you can see make up this mesh, so that I can work out the rotation and therefore angular acceleration of t...

sin, cos, tan and rounding error

I'm doing some trigonometry calculations in C/C++ and am running into problems with rounding errors. For example, on my Linux system: #include <stdio.h> #include <math.h> int main(int argc, char *argv[]) { printf("%e\n", sin(M_PI)); return 0; } This program gives the following output: 1.224647e-16 when the correct answer ...

c++ opengl converting model coordinates to world coordinates for collision detection

Hi, (This is all in ortho mode, origin is in the top left corner, x is positive to the right, y is positive down the y axis) I have a rectangle in world space, which can have a rotation m_rotation (in degrees). I can work with the rectangle fine, it rotates, scales, everything you could want it to do. The part that I am getting reall...

C# -Trigonometric code explaination (Physics)

This piece of code has been taken from a game built with XNA framework. I'd like some explanation of how it works in terms of trig and physics. ball.velocity = new Vector2((float)Math.Cos(cannon.rotation), (float)Math.Sin(cannon.rotation)); ball.rotation is the rotation of a sprite in...

Trigonometric functions on embedded system

sin and cos functions are slow and need a lot of resources to run on embedded systems. How does one calculate sin and cos functions in a more resource-saving and faster way? ...