Finding center point x,y,z of a circle created from 3 points in wobj0
Hello.
Could someone have a code in RAPID for finding coordinates x,y,z of a circle center created from 3 points A,B,C in wobj0.
0
Best Answer
-
Hello,
here is a routine for calculating the center point.
/BR
Micky
!**********************************************************
!* Calculation of the midpoint of circle from three *
!* positions on the circumference of the hole *
!* *
!* The orientation of the midpoint corresponds to *
!* Position p1 *
!**********************************************************
LOCAL FUNC robtarget UTL_cirCntr(
robtarget p1,
robtarget p2,
robtarget p3,
INOUT num Radius)
VAR pos p12;
VAR pos p13;
VAR pos p23;
VAR pos k2;
VAR pos pn12;
VAR pos pn13;
VAR num a;
VAR num b;
VAR num ai;
VAR num bi;
VAR num c;
VAR num d;
VAR num s;
VAR num kl;
VAR robtarget p0;
!
p12:=p2.trans-p1.trans;
p13:=p3.trans-p1.trans;
p23:=p3.trans-p2.trans;
a:=Sqrt(p12.x*p12.x+p12.y*p12.y+p12.z*p12.z);
b:=Sqrt(p13.x*p13.x+p13.y*p13.y+p13.z*p13.z);
c:=Sqrt(p23.x*p23.x+p23.y*p23.y+p23.z*p23.z);
s:=(a+b+c)/2;
ai:=1/a;
bi:=1/b;
Radius:=0.25*a*b*c/Sqrt(s*(s-a)*(s-b)*(s-c));
IF a>b THEN
p23:=p13;
p13:=p12;
p12:=p23;
a:=b;
ENDIF
pn12:=p12*ai;
pn13:=p13*bi;
k2:=pn12*pn13*pn12;
kl:=1/Sqrt(k2.x*k2.x+k2.y*k2.y+k2.z*k2.z);
k2:=kl*k2;
d:=Sqrt(Radius*Radius-a*a/4);
p0:=p1;
p0.trans:=p1.trans+0.5*p12+d*k2;
RETURN p0;
ENDFUNC
5
Answers
-
Thank you very much.
Regards.
0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings