trigonometry - Inverse-Kinematics: How to calculate angles for servos of a robotic arm to reach all possible points in a canvas?

I have a robotic arm composed of 2 servo motors. I am trying to calculate inverse kinematics such that the arm is positioned in the middle of a canvas and can move to all possible points in both directions (left and right). This is an image of the system Image. The first servo moves 0-180 (Anti-clockwise). The second servo moves 0-180 (clockwise). Here is my code: int L1 = 170; int L2 = 230; Vector shoulderV; Vector targetV; shoulderV = new Vector(0,0); targetV = new Vector(0,400); Vector difference = Vector.Subtract(targe...Read more

trigonometry - How does atan appear in haversine formula?

I am kinda new on this. I am about to convert math equation to code lately. So I started practicing on simple formulas such as Fibonacci numbers and haversine formula.But I am kinda confused with the haversine code on the following references;Using the Haversine Formula in JavascriptCalculate distance between two latitude-longitude points? (Haversine formula)Generally, what they do is,var R = 6371e3; // metresvar φ1 = lat1.toRadians();var φ2 = lat2.toRadians();var Δφ = (lat2-lat1).toRadians();var Δλ = (lon2-lon1).toRadians();var a = Math.sin(Δφ...Read more

trigonometry - Flipping an angle using radians

Hello all you math whizzes out there!I am struggling with a math problem I am hoping you can help me with. I have calculated an angle of direction using radians. Within OpenGL ES I move my guy by changing my point value as such:spriteLocation.x -= playerSpeed * cosf(playerRadAngle);spriteLocation.y -= playerSpeed * sinf(playerRadAngle);// playerRadAgnle is my angle of direction using radiansThis works very well to move my sprite in the correct direction. However, I have decided to keep my sprite "locked" in the middle of the screen and move t...Read more

trigonometry - Using the coordinates of two of a triangle's vertices to calculate the coordinates of the third

I know two coordinates of two vertices in a triangle (not aligned to an axis) and I'm attempting to calculate the coordinates of the third. a B ------- C \ | \ |C' \ | c \ | b \ | \ | \| AI know the coordinates of A and B, the lengths of a and c, and that the angle C will always be a right angle. I believe there can only be two possible solutions for the coordinates of C; the one drawn above, and one with C reflected about the line c, approximate...Read more

trigonometry - Adjusting initial bullet angle to match user set distance(scope zero) (for math gods)

So my question is pretty specific, which means it was pretty hard to find anything that could help me on google or stackoverflow. I want to give users the ability to set the distance/range on their guns. I have almost everything I need to make this happen, I just don't have the angle that I need to add on to the direction angle at which the bullet comes from. I don't know what equation/formula I would need to get this. I am not looking for anything code-specific, just an idea of what/how to do this.Since I do not know what formula to use, I jus...Read more

trigonometry - 2 Different Radians constant calculations what's the difference?

Most commonly I see in programs that convert radians to degrees and degrees to radians for trigonometry people always use two different ways to get the radian constant.double PI = 3.14159265358979;double Radians = (2 * PI) / 360;Most commonly I see the one shown below:double Radians = PI / 180;From my understanding they both seem to generate the same value, but it seems that the one with 360 looks better. After all it's the angle for a full circle and the other one uses the 180 which is half the circle, also I always learned that PI is for calc...Read more

trigonometry - How do arbitrary-precision libraries like mpmath evaluate simple trigonometric functions?

I ask for a brief explanation, pointing out the various acceleration methods involved. This is just for mere curiosity.For example the mpmath website tells that the exponential function formula is used for operations in the complex plane, but for now I'd like to keep it to the operations used over plain real numbers.Optionally, it would be nice to have a link to the source code sections where the actual calculations are performed in mpmath, I had no luck searching the downloadable sources....Read more

trigonometry - Solving equations with maxima

I can solve the equation bellow normally sin(b1*(x-c1)) = sin(b2*(x-c2))b1*(x-c1) = b2*(x-c2)c2 = x-(b1*(x-c1))/b2for c1 = 0, b1 = 1, b2 = 1.5, x = pi/2c2 = (x-(b1*(x-c1))/b2) = 0.523598775598299But when I try and do this in Maxima see below the answer is completely different what am I doing incorrectly? kill(all)$numer:true$phase1:0; freq1:1; freq2:1.5; x:pi/2; solve(sin(freq1*(x-phase1))=sin(freq2*(x-phase2)),phase2);Answer I get below...Read more

trigonometry - How to use maple to simplify trig expressions involving arccos and cos?

I'm having trouble convincing maple to simplify a complicated trig expression. It appears the bottleneck is that I don't know how to tell maple that it's OK to simplify expressions like:arccos(cos(x))into xInstead, if I issue:simplify(arccos(cos(x)));I just getarccos(cos(x));Is there some set of assumes that I should be using? My actual expression is much more complicated so I'd prefer a generic solution where the expressions inside arccos and cos might each be complicated expressions.Update:Here's the more complicated simplify example where th...Read more

trigonometry - Find a coordinate along a path

My trigonometry needs a little help.How would I go about calculating the point of the nearest possible intersection with a line along a rounded corner?Take this image:What I would like to know is, given that I know point a, and the dimensions of the rectangle, how would I find point b when the edges of the rectangle are curved?So far, as you can see, I've only managed to calculate the nearest edge of the rectangle as if it had right-angled corners.If it matters, I'm doing this in ActionScript 3. But example sudo-code will suffice....Read more

trigonometry - Finding Shortest Distance Between Two Parallel Lines, With Arbitrary Point

I need to write a reliable method to retrieve the answer to the following scenario...Given a line segment AB and an arbitrary point C, how would I find the closest point to A on a line parallel to AB that passes through point C? (Reliable mentioned above refers to the algorithms ability to find D while allowing the coordinates for A, B, and C to be completely arbitrary and unpredictable. I've ran in to a quite a few solutions that I was not able to adapt to all possible scenarios, sadly...)In the case of the data displayed in the picture below,...Read more