trigonometry

Given an angle and length, how do I calculate the coordinates

Assuming the upper left corner is (0,0) and I'm given an angle of 30 degrees, a starting point of (0,300), a line length of 600, how do I calculate the ending point of the line so that the line is representative of the angle given. The C pseudo-code is main() { int x,y; getEndPoint(30, 600, 0, 300, &x, &y); printf("end x=%d, en...

Calculating bounding box a certain distance away from a lat/long coordinate in Java

Given a coordinate (lat, long), I am trying to calculate a square bounding box that is a given distance (e.g. 50km) away from the coordinate. So as input I have lat, long and distance and as output I would like two coordinates; one being the south-west (bottom-left) corner and one being the north-east (top-right) corner. I have seen a ...

Easy Trig - Move an object in a position

I know this is quite easy trigonomety, however I was never introducted to vectors etc, and I'm at a loss understanding how this works. Given an object at point XY, and a direction N, how do you move that object in that direction? Also, given am object at point XY, and a destination at point XY, how do you move an object towards the des...

How to use the PI constant in C++

I want to use the PI constant and trigonometric functions in some C++ program. I get the trigonometric functions with include <math.h>. However, there doesn't seem to be a definition for PI in this header file. How can I get PI without defining it manually? ...

Fixed point inverse sine

Does anyone know a (preferably fast) way to calculate the sine of an angle in 4.12 fixed point? (where the result is either 32768ths of a circle or degrees) 4.12 fixed point means the number is 16 bits and is left shifted 12, so 1.0 becomes (1 << 12) or 4096. 0.5 is (0.5 << 12) == 2048, etc. ...

how to extrude a path in 3d ?

Hi, I'm trying to extrude a path in 3d. Nothing fancy yet, just following some points and using a regular polygon for 'tubing'. I'm using Processing for now to quickly prototype, but will later turn the code into OpenGL. My problem is rotating the 'joints' at the right angles. I think I have a rough idea how to get the angles, not sure...

Get the slope from one point and an angle in degrees.

In javascript, I am trying to draw a line that is at an angle that is user defined. Basically, I have a point (x,y) and an angle to create the next point at. The length of the line need to be 10px. Let's say that the point to start with is (180, 200)... if I give it angle "A" and the (I guess)hypotenuse is 10, what would my equation(s...

Programming math-based images for use in high-resolution artwork

I'm interested in creating poster-sized images that contain repeating patterns, similar to the two (public domain) images below, the Flower of Life and a Penrose tiling: My questions: How do people usually create images like these on a computer? I'm hoping the answer isn't, "Open Adobe Illustrator and guess at intersection points," ...

Find 2 points on a 3d object and get their distance

Hey, Ok. So I guess thing would to be envision new york city and beijing highlighted on google earth... I'm trying to figure out how to map points onto a 3d primitive object (a sphere), get their distance via any direction by the circumference, and their distance by diameter. The points are going to be latitude and longitude coordinat...

Is php deg2rad() equal to mysql radians()

Are these functions the same? If not, what is an appropriate php equivalent to mysql's radians() ...

How do I generate a fixed-waveform table in C?

What is the most efficient way to generate a signed float array of arbitrary length containing the amplitude (represented from 1 to -1) of a sine wave in C? ...

How to find the x,y coordinates of a rotated vector

Hi all, I found the best way of calculating the width and height of the bounding box of a vector post-rotation from a different stack overflow post. This worked great. My problem now is calculating the new x,y coordinates of the rotated vector's bounding box. Here is the my javascript. The newWidth, newHeight variables are correct -- the...

joystick deadzone calculation

My problem: given x and y, I need to calculate the x and y for the required joystick deflection. This is simple when there is no joystick deadzone -- I just use the x and y with no manipulation. When there is a deadzone, I want x=0 to be zero and x=non-zero to be the first value in that direction that is outside the deadzone. A square...

radians translating radians to degrees

I notice that translating radians to degrees and vice versa is like translating a percentage to a whole number and vice versa. for example , to get 60 percent of 345 you do the following 60 * 345/100 to get 60 degrees in radians you do 60 * 3.14/180 There is a pattern there BUT. we use 100 to compare percentages to a numbe. so why ...

Changing the direction of a ball on collision base on speed

I am creating a ping pong game. And I want to create the ability to control the direction of the ball based on the impact on the paddle. If the ball is coming down at vy = 4; vx = 4; and the paddle is moving to the left at vx = -5; I want the ball to slightly change its course depending on how fast the paddle is moving. It would probabl...

Implementing Trigonometric Inverse Functions in c#

I'm trying to implement inverse trigonometric functions in a C# application. Obviously I'm not talking about simple inverse sin, cos and tan seeing as those are all provided by the Math class. What I'm looking for is the inverses for sec, cosec and cotan: Func<double,double> secant = (d => (1 / Math.Cos(d))); Func<double,double> cosec...

why is this sin method returning a wrong answer?

Hey, working on some categories and I've bumped up against a weird issue, im basically expanding on a calculator class to add some trig methods, and i am getting an incorrect value when i call the sin method in the return in the form of a double. i send a value of 100.7 to the method and it returns 0.168231, from what i can see the corre...

Taylor series implementation in assembly language using 68hc11

How to implement Taylor series to calculate sine value in assembly using 68hc11. As 68hc11 does not support floating point, display value will be in integer..(e.g. multiply by 100 to make integer value). ...

Degree range (0-360) wrap around woes

I'm trying to trap the degrees that are X distance (fig: 45) away from a given degree (fig: 15). I'm getting caught up in the 360/0 wrap around. The given degrees are all normalized 0-360. Can someone please show me how to do this? I've included a graphic that illustrates my lacking aptitude. I swear on Michael Jackson's grave that I sc...

having trouble with getting circle coordinates

I am trying to utilize the example cited here: http://www.physicsforums.com/showthread.php?t=248191 I wrote a simple javascript that takes advantage of this example (or at least I intended it to), however, I'm totally bewildered by how it reacts to what I set as the angle. I'm EXPECTING it to behave where (assuming we use polar coordin...