Hey,
Im trying to find out the angle (in degrees) between two 2D vectors. I know I need to use trig but I'm not too good with it. This is what I'm trying to work out (the Y axis increases downward):
I'm trying to use this code at the moment, but it's not working at all (calculates random angles for some reason):
private float calcAng...
Given points ABC, how could I find angle ABC? I'm making a feehand tool for a vector drawing application and to minimize the number of points it generates, I wont add a points unless the angle of the mouse position and the last 2 points is greater than a certain threshold.
Thanks
what I had:
int CGlEngineFunctions::GetAngleABC( POINTFL...
I'm trying to understand the math on this raphael.js demo:
http://raphaeljs.com/pie.js
Checkout the sector method:
function sector(cx, cy, r, startAngle, endAngle, params) {
var x1 = cx + r * Math.cos(-startAngle * rad),
x2 = cx + r * Math.cos(-endAngle * rad),
y1 = cy + r * Math.sin(-startAngle * rad),
y2 ...
I feel stupid for asking this question (my trig is rusty), but I'm having a tough time.
Lets say I have an (x,y) that is always the same for the start point of a line and an (x,y) that changes for the end point of that same line. The line is also always 40px long. At the start of the program the line originates in a vertical orientati...
Given:
(x1,y1) = (0,0)
(x2,y2) = (0,-10)
Using the angle to C, how are the coordinates at C calculated?
...
Short question: Given a point P and a line segment L, how do I find the point (or points) on L that are exactly X distance from P, if it guaranteed that there is such a point?
The longer way to ask this question is with an image. Given two circles, one static and one dynamic, if you move the dynamic one towards the static one in a str...
Is it possible to distort an image using trigonometric functions like sine and cosine so that it comes out wavy.
If so, how.
PHP is the preferred language but it can be any...
...
Anybody know how to determine whether two sectors of the same circle intersect?
Let's say I have a sector A, expressed by starting and ending angles A1 and A2, and a sector B, expressed by starting angle B1 and ending angle B2. All angles ranges from 0..2*PI radians (or 0..360 degrees).
How to determine whether angle A intersects wit...
Hi, I'm using an NSTimer to animate an array of objects across the screen. Currently they move from left to right. However, I would like them to move in a circular fashion instead. How can I do this?
scrollItems = [NSTimer scheduledTimerWithTimeInterval:1.0/30.0
target:self
...
I am rotating an image around it center point but need to track a location on the image as it rotates.
Given:
Origin at 0,0
Image width and height of 100, 100
Rotation point at C(50,50)
Angle of "a" (say 90 degrees in this example)
Point P starts at (25,25) and after the rotation it is at Pnew(75,25)
I haven't touched trig in 20 y...
Sorry if this doesn't make sense... I know the length of the triangle segments and the xy coordinates of two points. How do I figure out the xy of the 3rd point?
...
I am making a simplified version of the ball physics app found at this SO question. I gained a lot from reading through the code and links provided at that question, but in my program I do not use vectors, I just update the coordinates of my balls (each of which has a random angle and speed) with trigonometry functions when they hit the...
So I am currently trying to make the game Asteroids for a class. The problem is, I haven't done any coding for about 3/4ths of a year since the last time I had the class and forgot almost everything I learned. I need to move the ship using thrust/acceleration but also cap it, and have friction so that when the thrust stops, the ship slow...
I have the following:
An image - a hand drawn map - of an area of roughly 600x400 meters. The image is drawn on top of Google Maps tiles.
The latitude/longitude (from Google Maps) of the corners of this image. Or put differently, I have the north and south latitude and the east and west longitude of the image.
A latitude/longitude coor...
I'm trying to do collision testing between a finite line segment, and an arc segment. I have a collision test which does line segment vs. line segment, so I was going to approximate these arc segments with line segments and run my existing test.
The data I have defining the arc segment(s) are three points. Two of which are endpoints th...
If I have calculated an intersection point between a line segment and a circle, how can I tell whether or not this intersection point lies on a segment of the circle?
I have the equations to tell whether or not a line segment intersects with the circle, and I also have the intersection point on that circle, but what I need to know is w...
We are developing a real-time system that will be performing sin/cos calculations during a time critical period of operation. We're considering using a lookup table to help with performance, and I'm trying to benchmark the benefit/cost of implementing a table. Unfortunately we don't yet know what degree of accuracy we will need, but pro...
I made this graph in wolfram alpha by accident:
Can you write code to produce a larger version of this pattern?
Can you make similar looking patterns?
Readable code in any language is good, but something that can be run in a browser would be best (i.e. JavaScript / Canvas). If you write code in other languages, please include a scr...
Hello,
Is there a more stable implementation for the cotangent function than return 1.0/tan(x);?
...
How do I calculate the pitch, yaw, and roll angles for a point in 3D space?
I'm working on a game where the player character must face towards an object that's flying around.
...