Controlling Servos with Trigonometry

/*
Control of a robotic insect leg.

The x and y position of the end of the leg is controlled by 2 servos
the aim is to enable the Arduino to position the tip of the leg based
on an input defining a target position.

The aim is to do this by calculating the side lengths and angles of triangles

My school education took place some 50 plus years ago where it was considered
that an understanding algebra and trigerometry to meet my needs could be
delt with in a lesson that lasted almost one hour. Now and after a few days of head
scratching I feel that I have a basic understanding of what is needed.

I have now become stuck in trying to implement this into Arduino code.
I have created an idea of how I think the code should look, I relise that this
will not run, and need to know where and what I should be looking for to turn
this idea into code that will work.
I,m not looking for some one to write the code I simply want some pointers
as to where and what I should be looking for, However if there is some sample of code
along these lines I may be able to work out a way to use it for my own purposes
*/


// Find the length of the side of a triangle where the length of 2 sides of a triangle
// and one angle is known

// sides of a triangle
float a = 10;
float b = 5;
float c;

//angles of a triangle
float A;
float C = 80;

c = (squRoot(( a * a ) + ( b * b )) - (2 * a * b * (C cosine)));


// Find the angle of a triangle when all the side lengths are known

//sides of a triangle
const int a = 10;
const int b = 15;
float c; // this value would come from some where else in the code

//angles of the triangle
float B;
float C;

B = ((( a * a ) + (c * c) - ( b x b )) / (2 * a * c (cosine ?)));

myservo.write(B);

Was there a question?
Can we expect code tags any time soon?

I have been unable to find any information as to how I can write this piece of code can anyone suggest what I should be looking for and where

If the question is being asked in the wrong place please tell me where it should be posted

Are you asking about cos() and sqrt() ?

yes but where to find out how they should be used

Arduino reference page

Yes, read it several times, also math libery , unfourtunatly all beyond me, Differant concepts of code I can usaly grasp, Possibly it is my lack of knolage of trigonometry thats the real problem may be I could figger it out if I could find some code in which it is used. Thanks for your time anway

Possibly it is my lack of knolage of trigonometry thats the real problem

Your spelling and punctuation could do with some work too if you are going to write computer programs. I can make sense of what you wrote but with a compiler it is either right or wrong and nothing in between and certainly no guesses as to what you really meant.

The main problem with dyslexia is that those without its advantages can spell it but fail to understand it

I’ll try to explain, I’ve lived with dyslexia for well over 60 years, I’m well aware of the limitations this places on me, I will never be a proof reader, and I do not know my left from my right, But like all those that are dyslectic, I have learnt strategies to cope with these situations. The Arduino IDE provides a degree of text color, and variables generated by me are named in such a way as they do not create a problem, the snippet of code that I posted was only to try to clarify and demonstrate what I am trying to achieve and The most common mistakes I make are related to as it were code grammar.
But my biggest problem is expanding my code vocabulary, and at this moment it is trying to understand how I can get my sketch to calculate the length of a triangle side or a missing angle

Perfect, I’ve no idea what it all means There is a few words like radians, that I need to look up, But give me 24hours or so to experiment with what you have given me and I should be on my way
Many many thanks

So

' Degree' int x = 45;

//convert Degrees into radian

'Radian ' int x =(180*2 /45);

I,ll try creating a sketch incorporating this tomorrow, again thanks for the pointer

  'Radian '   int x =(180*2 /45);

No.
360 degrees is 2pi radians.
180 degrees is pi radians.
45 degrees is one quarter of pi radians.
"int" is not a datatype normally associated with radians

access2it:
So

' Degree' int x = 45;

//convert Degrees into radian

'Radian ' int x =(180*2 /45);

I,ll try creating a sketch incorporating this tomorrow, again thanks for the pointer

You can't store transcendental numbers in an int data type. It should be a float type.