当前位置:网站首页>[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
2022-07-05 08:02:00 【Changjiang houlang blog】
brothers , Hello everyone . Today, we will bring you the formula for calculating the center and radius of the arc at three points of the space arc . stay Trio in , Integrated calculation functions , Our goal today is to realize this calculation formula by ourselves .
' Import calculation data
TABLE(100,0,0,0,5,5,5,5,0,0)
' Write your own algorithm
calcriclecen(100,FALSE)
PRINT "XYZ 1=",TABLE(100+10),TABLE(100+11),TABLE(100+12)
'Trio Original algorithm implementation
SPHERE_CENTRE(100+3, 100+6, 100+10)
PRINT "XYZ 2=",TABLE(100+10),TABLE(100+11),TABLE(100+12)
Trio Instructions help
From this instruction, we can see , Its starting point must be 0,0,0, This means that the calculation must be incremental .
Let's look at our own handwriting Algorithm :
'=================================================================
'=================================================================
' Calculate the center and radius of the arc at three points in a given space
'partable Given input parameters
'Table0-2 Given P Point coordinates ( The starting point )
'Table3-5 Given Q Point coordinates ( Midpoint )
'Table6-8 Given Q Point coordinates ( End )
'Table10-13 Output arc center XYZR
'needprint Confirm whether the calculation process data needs to be printed false No printing ,true Print
FUNCTION calcriclecen(partable AS INTEGER,needprint AS BOOLEAN) AS BOOLEAN
' Input parameter check
IF partable<0 OR partable>511980 THEN
PRINT "Parameter out of range,Par=",partable
RETURN FALSE
ENDIF
' Calculate the center and radius of the arc at three points in a given space
DIM dpx,dpy,dpz AS FLOAT
dpx=TABLE(partable+0)
dpy=TABLE(partable+1)
dpz=TABLE(partable+2)
DIM dqx,dqy,dqz AS FLOAT
dqx=TABLE(partable+3)
dqy=TABLE(partable+4)
dqz=TABLE(partable+5)
DIM drx,dry,drz AS FLOAT
drx=TABLE(partable+6)
dry=TABLE(partable+7)
drz=TABLE(partable+8)
' Print process data
IF needprint THEN
PRINT "========================="
PRINT "Input Parmater:"
PRINT "P [XYZ]=",dpx,dpy,dpz
PRINT "Q [XYZ]=",dqx,dqy,dqz
PRINT "R [XYZ]=",drx,dry,drz
ENDIF
' Output space origin and radius
DIM dx0,dy0,dz0,dr AS FLOAT
DIM dx1,dy1,dz1 AS FLOAT
dx0=0
dy0=0
dz0=0
dr=0
'-------------------------------------------
DIM pi0,pj0,pk0 AS FLOAT
DIM x1,x2,y1,y2,z1,z2 AS FLOAT
x1=dqx-dpx
x2=drx-dpx
y1=dqy-dpy
y2=dry-dpy
z1=dqz-dpz
z2=drz-dpz
pi0=y1*z2-z1*y2
pj0=z1*x2-x1*z2
pk0=x1*y2-y1*x2
' Print process data
IF needprint THEN
PRINT "Proc Parmater:"
PRINT "IJK =",pi0,pj0,pk0
ENDIF
IF (pi0=0) AND (pj0=0) AND (pk0=0) THEN
STOP
ENDIF
'-------------------------------------------
' seek PQ and PR The vertical line of the line
'---------------------
'1, too PQ The midpoint of (Mx,My,Mz)
DIM dmx,dmy,dmz AS FLOAT
dmx=(dpx+dqx)/2
dmy=(dpy+dqy)/2
dmz=(dpz+dqz)/2
' And (Mi,Mj,Mk)=(pi,pj,pk)×(x1,y1,z1) vertical
DIM dmi,dmj,dmk AS FLOAT
dmi=pj0*z1-pk0*y1
dmj=pk0*x1-pi0*z1
dmk=pi0*y1-pj0*x1
IF needprint THEN
PRINT "PQ M=",dmi,dmj,dmk
ENDIF
'---------------------
'2, too PR The midpoint of (Nx,Ny,Nz)
DIM dnx,dny,dnz AS FLOAT
dnx=(dpx+drx)/2
dny=(dpy+dry)/2
dnz=(dpz+drz)/2
' And (Ni,Nj,Nk)=(pi,pj,pk)×(x2,y2,z2) vertical
DIM dni,dnj,dnk AS FLOAT
dni=pj0*z2-pk0*y2
dnj=pk0*x2-pi0*z2
dnk=pi0*y2-pj0*x2
IF needprint THEN
PRINT "PR M=",dni,dnj,dnk
ENDIF
' Combined calculation
DIM ds AS FLOAT
'ds=dNi*dNi+dNj*dNj+dNk*dNk
ds=SQR(pi0*pi0+pj0*pj0+pk0*pk0)
IF ds=0 THEN
dx1=0
dy1=0
dz1=0
ELSE
dx1=pi0/ds
dy1=pj0/ds
dz1=pk0/ds
ENDIF
IF needprint THEN
PRINT "DX1 =",dx1,dy1,dz1,ds
ENDIF
'-------------------------------------------
' The two vertical lines obtained are {X=dMx+dMi*tm;Y=dMy+dMj*tm;Z=dMz+dMk*tm;}
' or (x-dmx)/dmi=(y-dmy)/dmj=(z-dmz)/dmk
' {X=dNx+dNi*tn;Y=dNy+dNj*tn;Z=dNz+dNk*tn;}
' or (x-dnx)/dni=(y-dny)/dnj=(z-dnz)/dnk;
' Solve the intersection of two straight lines
DIM tm,tn AS FLOAT
tn=((dmy-dny)*dmi+dmj*(dnx-dmx))/(dnj*dmi-dmj*dni)
tm=(dnx+dni*tn-dmx)/dmi
'dx0,dy0,dz0,dr
dx0=INT((dmx+dmi*tm)*100000+0.5)/100000
dy0=INT((dmy+dmj*tm)*100000+0.5)/100000
dz0=INT((dmz+dmk*tm)*100000+0.5)/100000
dr=INT((SQR((dx0-dpx)*(dx0-dpx)+(dy0-dpy)*(dy0-dpy)+(dz0-dpz)*(dz0-dpz)))*100000+0.5)/100000
TABLE(partable+10,dx0,dy0,dz0,dr)
IF needprint THEN
PRINT "Out Parmater:"
PRINT "OUT X Y Z R =",dx0,dy0,dz0,dr
PRINT "========================="
ENDIF
RETURN TRUE
ENDFUNC
'=================================================================
Calculate the center and radius of the arc by giving three points in space
Run the result test
The two methods are consistent !
The task of this course is over , Thank you for watching ...
边栏推荐
- Screen record of the opening ceremony of the Beijing winter olympics 2
- C language uses arrays to realize the intersection, union, difference and complement of sets
- mysql 盲注常见函数
- Altium Designer 19.1.18 - 导入板框
- C WinForm [realize the previous and next selection pictures] - practice 7
- UEFI development learning 3 - create UEFI program
- Halcon's practice based on shape template matching [2]
- How to define guid in AMI code
- Shell script basic syntax
- Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
猜你喜欢
Measurement fitting based on Halcon learning [i] fuse Hdev routine
Beijing Winter Olympics opening ceremony display equipment record 3
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
Record the opening ceremony of Beijing Winter Olympics with display equipment
Introduction of air gap, etc
Altium Designer 19.1.18 - 清除测量距离产生的信息
C WinForm [view status bar -- statusstrip] - Practice 2
Altium designer 19.1.18 - change the transparency of copper laying
High end electronic chips help upgrade traditional oil particle monitoring
UEFI development learning 3 - create UEFI program
随机推荐
Embedded composition and route
Measurement fitting based on Halcon learning [i] fuse Hdev routine
Altium designer 19.1.18 - clear information generated by measuring distance
1089 Insert or Merge 含测试点5
如何进行导电滑环选型
Fundamentals of C language
Software designer: 03 database system
Network port usage
万字详解八大排序 必读(代码+动图演示)
1-stm32 operation environment construction
Step motor generates S-curve upper computer
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
Programming knowledge -- assembly knowledge
·Practical website·
Altium designer 19.1.18 - hide the fly line of a network
C language # and #
PMSM dead time compensation
2021-10-28
Gradle composite construction
Altium Designer 19.1.18 - 导入板框