Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple returns statement #45

Open
kobbled opened this issue Dec 29, 2022 · 0 comments
Open

Multiple returns statement #45

kobbled opened this issue Dec 29, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@kobbled
Copy link
Owner

kobbled commented Dec 29, 2022

tp+

def circleCenter3Points(x1,y1,z1,x2,y2,z2,x3,y3,z3) : numreg, numreg, numreg
    a = x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - x3 * y2
    b = (Mth::pow(x1, 2) + Mth::pow(y1, 2)) * (y3 - y2)
    c = (Mth::pow(x1, 2) + Mth::pow(y1, 2)) * (x2 - x3)
    d = (Mth::pow(x3, 2) + Mth::pow(y3, 2)) * (x2 * y1 - x1 * y2)
    
    x = -b / (a * 2) 
    y = -c / (a * 2)    
    z = (z1+z2+z3)/3

   return(x, y, z)
end

center := R[30..33]

center = circleCenter3Points(X1,Y1,Z1,X2,Y2,Z3,X3,Y3,Z3)

LS would turn into

/MN
 : CALL CIRCLECENTER3POINTS(X1,Y1,Z1,X2,Y2,Z3,X3,Y3,Z3,30,31,32) ;
/END
/MN
 : R[50:a]=(AR[1]*(AR[5]-AR[8])-AR[2]*(AR[4]-AR[7])+AR[4]*AR[8]-AR[7]*AR[5]) ;
 : CALL MTH_POW(AR[1],2,57) ;
 : CALL MTH_POW(AR[2],2,58) ;
 : R[51:b]=((R[57:dvar1]+R[58:dvar2])*(AR[8]-AR[5])) ;
 : CALL MTH_POW(AR[1],2,59) ;
 : CALL MTH_POW(AR[2],2,60) ;
 : R[52:c]=((R[59:dvar3]+R[60:dvar4])*(AR[4]-AR[7])) ;
 : CALL MTH_POW(AR[7],2,61) ;
 : CALL MTH_POW(AR[8],2,62) ;
 : R[53:d]=((R[61:dvar5]+R[62:dvar6])*(AR[4]*AR[2]-AR[1]*AR[5])) ;
 :  ;
 : R[54:x]=(R[51:b]*(-1)/(R[50:a]*2)) ;
 : R[55:y]=(R[52:c]*(-1)/(R[50:a]*2)) ;
 : R[56:z]=((AR[3]+AR[6]+AR[9])/3) ;

 : ! Multiple return ;
 : R[AR[10]]=R[54:x] ;
 : R[AR[11]]=R[55:y] ;
 : R[AR[12]]=R[56:z] ;
/END
@kobbled kobbled added the enhancement New feature or request label Dec 29, 2022
@kobbled kobbled self-assigned this Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant