- added makeauxub to tasub
- fixes for MARS - extended maximize to honour maxpts and the in360 flag - added regression histmem driver
This commit is contained in:
111
tasub.c
111
tasub.c
@ -9,6 +9,7 @@
|
||||
#include <assert.h>
|
||||
#include "sics.h"
|
||||
#include "lld.h"
|
||||
#include "trigd.h"
|
||||
#include "tasub.h"
|
||||
#include "tasdrive.h"
|
||||
/*------------------- motor indexes in motor data structure ---------*/
|
||||
@ -875,8 +876,100 @@ static void listDiagnostik(ptasUB self, SConnection *pCon){
|
||||
}
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
static int calcAuxUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
int argc, char *argv[]){
|
||||
int status;
|
||||
tasReflection r1, r2;
|
||||
char pBueffel[256];
|
||||
MATRIX UB = NULL, B = NULL;
|
||||
|
||||
if(argc < 5){
|
||||
SCWrite(pCon,
|
||||
"ERROR: not enough arguments for UB calculation, need HKJL of second plane vector",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!SCMatchRights(pCon,usUser)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[2],&r2.qe.qh);
|
||||
if(status != TCL_OK){
|
||||
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[2]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[3],&r2.qe.qk);
|
||||
if(status != TCL_OK){
|
||||
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[3]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
status = Tcl_GetDouble(InterpGetTcl(pSics),argv[4],&r2.qe.ql);
|
||||
if(status != TCL_OK){
|
||||
snprintf(pBueffel,255,"ERROR: failed to convert %s to number",argv[4]);
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = findReflection(self->reflectionList, 0,&r1);
|
||||
if(status != 1){
|
||||
snprintf(pBueffel,255,"ERROR: cannot find first reflection");
|
||||
SCWrite(pCon,pBueffel,eError);
|
||||
return 0;
|
||||
}
|
||||
B = mat_creat(3,3,ZERO_MATRIX);
|
||||
if(B == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory creating B matrix",eError);
|
||||
return 0;
|
||||
}
|
||||
status = calculateBMatrix(self->cell,B);
|
||||
if(status < 0){
|
||||
SCWrite(pCon,"ERROR: bad cell constants, no volume",eError);
|
||||
mat_free(B);
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = makeAuxReflection(B, r1, &r2,self->machine.ss_sample);
|
||||
mat_free(B);
|
||||
if(status < 0){
|
||||
SCWrite(pCon,"ERROR: out of memory in makeAuxUB",eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
UB = calcTasUBFromTwoReflections(self->cell,r1,r2,&status);
|
||||
if(UB == NULL){
|
||||
switch(status){
|
||||
case UBNOMEMORY:
|
||||
SCWrite(pCon,"ERROR: out of memory calculating UB matrix",eError);
|
||||
break;
|
||||
case REC_NO_VOLUME:
|
||||
SCWrite(pCon,"ERROR: bad cell constants, no volume",eError);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if(mat_det(UB) < .000001){
|
||||
SCWrite(pCon,"ERROR: invalid UB matrix, check reflections",eError);
|
||||
return 0;
|
||||
}
|
||||
if(self->machine.UB != NULL){
|
||||
mat_free(self->machine.UB);
|
||||
}
|
||||
if(self->machine.planeNormal != NULL){
|
||||
mat_free(self->machine.planeNormal);
|
||||
}
|
||||
self->machine.UB = UB;
|
||||
self->machine.planeNormal = calcPlaneNormal(r1,r2);
|
||||
self->ubValid = 1;
|
||||
SCparChange(pCon);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
/*------------------------------------------------------------------*/
|
||||
static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
int argc, char *argv[]){
|
||||
int idx1, idx2, status;
|
||||
tasReflection r1, r2;
|
||||
char pBueffel[256];
|
||||
@ -884,8 +977,8 @@ static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,
|
||||
"ERROR: not enough arguments for UB calculation, need index of two reflections",
|
||||
eError);
|
||||
"ERROR: not enough arguments for UB calculation, need index of two reflections",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -955,10 +1048,20 @@ static int calcUB(ptasUB self, SConnection *pCon, SicsInterp *pSics,
|
||||
/*-----------------------------------------------------------------*/
|
||||
static int calcUBFromCell(ptasUB self, SConnection *pCon){
|
||||
MATRIX B, U, UB;
|
||||
tasReflection r1;
|
||||
int status;
|
||||
|
||||
B = mat_creat(3,3,UNIT_MATRIX);
|
||||
U = mat_creat(3,3,UNIT_MATRIX);
|
||||
status = findReflection(self->reflectionList, 0,&r1);
|
||||
if(status == 1) {
|
||||
/*
|
||||
U[0][0] = Cosd(r1.angles.a3);
|
||||
U[0][1] = -Sind(r1.angles.a3);
|
||||
U[1][0] = Sind(r1.angles.a3);
|
||||
U[1][1] = Cosd(r1.angles.a3);
|
||||
*/
|
||||
}
|
||||
if(B == NULL || U == NULL){
|
||||
SCWrite(pCon,"ERROR: out of memory in calcUBFromCell",eError);
|
||||
return 0;
|
||||
@ -1459,6 +1562,8 @@ int TasUBWrapper(SConnection *pCon,SicsInterp *pSics, void *pData,
|
||||
return 1;
|
||||
} else if(strcmp(argv[1],"makeub") == 0){
|
||||
return calcUB(self,pCon,pSics,argc,argv);
|
||||
} else if(strcmp(argv[1],"makeauxub") == 0){
|
||||
return calcAuxUB(self,pCon,pSics,argc,argv);
|
||||
} else if(strcmp(argv[1],"makeubfromcell") == 0){
|
||||
return calcUBFromCell(self,pCon);
|
||||
} else if(strcmp(argv[1],"calcang") == 0){
|
||||
|
Reference in New Issue
Block a user