Question: From student resources and discussion notes, create a math object that calculates the two angles needed to move arm to (x,y). 1. use a class

From student resources and discussion notes, create a math object that calculates the two angles needed to move arm to (x,y).

1. use a class object

2. use a point object and angle object.

3. (x,y) supplied, (l1, l2) arm lengths supplied, angles returned.

S

#include "RoboMath.h"

#include

RoboMath::RoboMath(double A1, double A2)

{

Arm1 = A1;

Arm2 = A2;

}

double RoboMath::GetAngle1()

{

return asin((Arm2 * sin(GetAngle2())) /

(sqrt(pow( xy.X,2)+pow( xy.Y,2))))

+ atan(xy.Y/xy.X);

}

double RoboMath::GetAngle2()

{

return acos(( pow( xy.X,2) + pow( xy.Y,2)-

(Arm1*Arm1)-(Arm2*Arm2))/(2*Arm1*Arm2));

}

AnglePair RoboMath::RoboMove(PointXY XYPos){

AnglePair Temp;

xy.X = XYPos.X;

xy.Y = XYPos.Y;

Temp.Ang1 = GetAngle1();

Temp.Ang2 = GetAngle2();

return Temp;

}

tarting point:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!