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

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

I wonder why this doesn't work as expected:assume(x+y < %pi/2);assume(x+y > -%pi/2);atan(tan(x+y));It reduces to:atan(tan(x+y))i.e. not at all. I would have expected it to reduce to:x+y...Read more

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

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

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

I need to convert polar coordinates from decimal degrees to Cartesian points.I know there are many formulas but I need a formula that uses only sine and cosine (no arcsine, arccosine), and that does not involve too many calculations.The coordinates are all within a radius of 150km so it does not matter that it is not precise with coordinates far from each other.Thanks!...Read more

A quadratic bezier curve needs these three points, but I do not have an ordered pair of p1. Instead, I have the ordered pair of points hereThe middle point (P1) is the highest point of the parabola.The parabola is equal in both sidesHow do I get the 3 points from image 1 using the points from image 2?...Read more

How to estimate the angle between line y = 1000 x and y = 999 x?I use the calculator and get 10^(-6) but how to approximate it by hand. Does it relate to Taylor Expansion?...Read more

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

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

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

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

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

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