trigonometry

Calculating Distance Between 2 Cities

How do you calculate the distance between 2 cities? ...

Triangle Trigonometry (ActionScript 3)

I am trying to write a formula in ActionScript 3 that will give me var "z" (please see image below) in degrees, which I will then convert to radians. I will already know the value of vars "x" and "y". Using trigonometry, how can I calculate the length of the hypotenuse and therefore the variable angle of var z? A solution in either AS3...

Is there a built in method for converting radians to degrees?

I run into this occasionally and always forget how to do it. One of those things that pop up ever so often. Also, what's the formula to convert angles expressed in radians to degrees and back again? ...

Triangle mathematics for game development

I'm trying to make a triangle (isosceles triangle) to move around the screen and at the same time slightly rotate it when a user presses a directional key (like right or left). I would like the nose (top point) of the triangle to lead the triangle at all times. (Like that old asteroids game). My problem is with the maths behind this. A...

Making a custom Sin() function in Java

I have to create the sin function from scratch in my Comp Sci class, and I think I got it down. But it still has some problems. If I put in a value of .5PI or less it works. Otherwise it doesn't. Any help would be greatly appreciated. double i=1; double sinSoFar = 0; int term = 1; while(i >= .000001) { i = pow(-1, term + 1) * pow(sinOf...

Help with trigonometry and circle geometry with JavaFX game

Im trying to get into some basic JavaFX game development and I'm getting confused with some circle maths. I have a circle at (x:250, y:250) with a radius of 50. My objective is to make a smaller circle to be placed on the circumference of the above circle based on the position of the mouse. Where Im getting confused is with the coordi...

Calculating rotation along a path.

Hello, I am trying to animate an object, let's say its a car. I want it go from point x,y,z to point x,y,z. It moves to those points, but it appears to be drifting rather than pointing in the direction of motion. So my question is: how can I solve this issue in my updateframe() event? Could you point me in the direction of some good r...

How do Trigonometric functions work?

So in high school math, and probably college, we are taught how to use trig functions, what they do, and what kinds of problems they solve. But they have always been presented to me as a black box. If you need the Sine or Cosine of something, you hit the sin or cos button on your calculator and you're set. Which is fine. What I'm wonder...

Determining if a lat-long rect and a circle on a sphere overlap

Suppose I have the following: A region defined by minimum and maximum latitude and longitude (commonly a 'lat-long rect', though it's not actually rectangular except in certain projections). A circle, defined by a center lat/long and a radius How can I determine: Whether the two shapes overlap? Whether the circle is entirely contai...

Converting polar coordinates to rectangular coordinates

Convert angle in degrees to a point How could I convert an angle (in degrees/radians) to a point (X,Y) a fixed distance away from a center-point. Like a point rotating around a center-point. Exactly the opposite of atan2 which computes the angle of the point y/x (in radians). Note: I kept the original title because that's what peo...

Cosine similarity of vectors

Hi how do i find the cosine similarity between vectors. I need to find the similarity to measure the relatedness between two lines of text.Can someone help me with the code.what java classes and methods to use. For example i ve two sentences like 1.system for user interface and 2.user interface machine and their respective vectors afte...

Fast transcendent / trigonometric functions for Java

Since the trigonometric functions in java.lang.Math are quite slow: is there a library that does a quick and good approximation? It seems possible to do a calculation several times faster without losing much precision. (On my machine a multiplication takes 1.5ns, and java.lang.Math.sin 46ns to 116ns). Unfortunately there is not yet a way...

How should I tackle ARCTAN (and prevent deviding by zero) without the convenience of ARCTAN2(n,m) being available?

I try to determine the angle from a point (n,m) to (0,0). Without arctan2 being available, I'm running into the problem that m can be 0, which leads to a possible division by zero. What would be an elegant, correct solution to tackling this issue? ...

Implementing Table-Lookup-Based Trig Functions

For a videogame I'm implementing in my spare time, I've tried implementing my own versions of sinf(), cosf(), and atan2f(), using lookup tables. The intent is to have implementations that are faster, although with less accuracy. My initial implementation is below. The functions work, and return good approximate values. The only probl...

cocos2d help find points on a circle

I am trying to solve a tricky math problem, in a cocos2d for iphone context. Basically I have a roullette wheel which is rotating over time. I want to have a Sprite latch onto the wheel at certain points (like compass ordinal points N, S, E, W) and bounce off at all other points. I have the image of the wheel rotating, and just need t...

AS3 (or any language) trig library for triangles?

Does anyone know of a library for easily dropping in parameters of angles and lengths of sides, and letting it automagically extrapolate the non-given angles and lengths using trig? Even if it had lame performance, it would be very useful for prototyping, and performance could be optimized (even supplying table lookup and the sort). If...

python inverse trigonometry (particularly arcsin)

I'm currently trying to get something to run involving trigonometry but I've run across a hitch involving the math.asin function (it also applies to acos and atan but in those cases it less affects what I'm trying to do). The issue is best summarised by two posts from a help thread I found about it elsewhere; Sorry, I have just tried...

How do I calculate a point on a circle’s circumference?

How can the following function be implemented in various languages? Calculate the (x,y) point on the circumference of a circle, given input values of: Radius Angle Origin (optional parameter, if supported by the language) ...

Trigonometrical ratios for angles higher than 360

Is there any use of Sin(720)or Cos(1440) (angles in degrees)? Whether in computer programming or in any other situation? In general, is there any use of Sin/Cosine/Tan of any angle greater than 360? In Physics we do use dot products and cross products a lot, but even they require angles less than 180 degrees always. Hi All, I know how ...

How to determine the accuracy of Pi (π)

Optimizing a game we're developing, we're running into the phase where every CPU cycle won counts. We using radians for position calculations of objects circling around other objects and I want to cut the needless accuracy in my lookup tables. For that, we make heavy use of a predefined Pi. How accurate should this Pi be? So, my questio...