Home > Net >  For a rectangular XY offset the center of the workpiece and the rotation Angle
For a rectangular XY offset the center of the workpiece and the rotation Angle

Time:11-04

Doing a project recently, put down the workpiece the workpiece, the location and does not comply with the design values,
What do you want to be a software compensation procedures,
By measuring the two Angle of the workpiece coordinate data, to find the center of the work pieces of artifacts, y offset and rotation Angle,
Hope to have experience in counsel, thank

CodePudding user response:

O Angle when applied triangle knowledge can be obtained

CodePudding user response:

The junior high school geometry application I have returned to the math teacher, you can ask her to come back.

CodePudding user response:

For example on the left on behalf of A, right on behalf of B, her left on behalf of the C, right on behalf of D, X and Y coordinates is container, offset according to now - you can get the original; X - x y - y
Rotation Angle, By - Ay=right-angle triangle height, slope length, Bx - Ax=triangle and the length, when calculating the Angle, it is not problem, forget to triangle formula, you look for it

CodePudding user response:

///& lt; Summary> 
///coordinate calculation according to two offset and rotation quantity
///& lt;/summary>
///& lt; Param name="Pos" & gt;
///& lt; Param name="result" & gt;
Public void CalculateOffset (double [] Pos, ref double [] result)
{
Double result1, result2, result3 result4;
Double result11 result22, result33, result44;
Double result111 result222, result333 result444;
Double offset1 and offset2 offset3;
The result of [0]=0;
The result of [1]=0;
The result of [2]=0;
If (Pos) Length!=8)
return;
Double angle1;
Double angle2;
Double offsetx1=Pos [2] - Pos [0];
Double offsety1=Pos [3] - Pos [1];
Double offsetx2=Pos [6] - Pos [4];
Double offsety2=Pos [7] - Pos [5];

If (offsetx1==0)
{
If (offsety1 & gt; 0)
Angle1=90;
The else
Angle1=270;
}
The else
Angle1=(180/Math. PI) * math.h Atan (offsety1/offsetx1);
If (offsetx2==0)
{
If (offsety2 & gt; 0)
Angle2=90;
The else
Angle2=270;
}
The else
Angle2=(180/Math. PI) * math.h Atan (offsety2/offsetx2);
Double resultangle;
Double resultangle1=(angle2 - angle1);
Double resultangle2=(angle2 - angle1) + 180.
Double resultangle3=(angle2 - angle1) - 180;
Resultangle=resultangle1 * Math. PI/180;
Result1=Pos [4] - Math. Cos (resultangle) * Pos [0] + math.h Sin (resultangle) * Pos [1];
Result2=Pos [5] - Math. Sin (resultangle) * Pos [0] - Math. Cos (resultangle) * Pos [1];
Result3=Pos [6] - Math. Cos (resultangle) * Pos [2] + math.h Sin (resultangle) * Pos [3];
Result4 Pos [7] - Math.=Sin (resultangle) * Pos [2] - Math. Cos (resultangle) * Pos [3];
Offset1=Math. Abs (result3 - result1) + math.h Abs (result4 - result2);
Resultangle=resultangle2 * Math. PI/180;
Result11=Pos [4] - Math. Cos (resultangle) * Pos [0] + math.h Sin (resultangle) * Pos [1];
Result22 Pos [5] - Math.=Sin (resultangle) * Pos [0] - Math. Cos (resultangle) * Pos [1];
Result33=Pos [6] - Math. Cos (resultangle) * Pos [2] + math.h Sin (resultangle) * Pos [3];
Result44 Pos [7] - Math.=Sin (resultangle) * Pos [2] - Math. Cos (resultangle) * Pos [3];
Offset2=Math. Abs (result33 - result11) + math.h Abs (result44 - result22);
Resultangle=resultangle3 * Math. PI/180;
Result111=Pos [4] - Math. Cos (resultangle) * Pos [0] + math.h Sin (resultangle) * Pos [1];
Result222 Pos [5] - Math.=Sin (resultangle) * Pos [0] - Math. Cos (resultangle) * Pos [1];
Result333=Pos [6] - Math. Cos (resultangle) * Pos [2] + math.h Sin (resultangle) * Pos [3];
Result444 Pos [7] - Math.=Sin (resultangle) * Pos [2] - Math. Cos (resultangle) * Pos [3];
Offset3=Math. Abs (result333 - result111) + math.h Abs (result444 - result222);

If (offset3 & lt; Offset1 & amp; & Offset3 & lt;=offset2)
{
The result of [0]=result111;
The result of [1]=result222;
The result of [2]=resultangle3;
}
Else if (offset2 & lt; Offset1 & amp; & Offset2 & lt;=offset3)
{
The result of [0]=result11;
The result of [1]=result22;
The result of [2]=resultangle2;
}
The else
{
The result of [0]=result1;
The result of [1]=result2;
The result of [2]=resultangle1;
}
}

CodePudding user response:

This is very simple, just put a tangent function,
Double r=Math. Atan (20/20);

But see you rotate Angle, your measurements seem to have a problem, another due to the rotation and translation problems, you need a set of formula, gives you a vector algorithm for reference,
'* * * * * * (x1, y1) for rotating arbitrary point, (x2, y2) as the center of rotation, if it is clockwise Angle is theta, the rotation (x, y) as the new coordinates * *
'* * * * * * x=(x1, x2) cosine theta - (y1, y2) sine theta + x2 * *
'* * * * * * y=(x1, x2) sine theta + (y1, y2) cosine theta + y2

CodePudding user response:

What is inverse trigonometric function, trigonometric function? Measure the same edge two vertices values, to calculate the horizontal and vertical deviation between two points, can calculate the rotation Angle, according to the center of rotation Angle can calculate the relative coordinates, and then calculate the deviation,

CodePudding user response:

Thank you very much!!!!!!
  •  Tags:  
  • C#
  • Related