Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c Conflicts: .gitignore SICSmain.c asynnet.c confvirtualmot.c counter.c devexec.c drive.c event.h exebuf.c exeman.c histmem.c interface.h motor.c motorlist.c motorsec.c multicounter.c napi.c napi.h napi4.c network.c nwatch.c nxscript.c nxxml.c nxxml.h ofac.c reflist.c scan.c sicshipadaba.c sicsobj.c site_ansto/docs/Copyright.txt site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl statusfile.c tasdrive.c tasub.c tasub.h tasublib.c tasublib.h
This commit is contained in:
31
vector.c
31
vector.c
@@ -189,6 +189,37 @@ double angleBetween(MATRIX v1, MATRIX v2)
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
/*-----------------------------------------------------------------------
|
||||
angleBetween gives only angles between 0 - 180. This is also the
|
||||
only thing there is; the direction of the rotation depends on the
|
||||
viewpoint and thus is ill defined. This version determines the
|
||||
sign of the rotation from v3[2]. I made a special version in order not
|
||||
to trouble other uses of angleBetween.
|
||||
-----------------------------------------------------------------------*/
|
||||
|
||||
double tasAngleBetween(MATRIX v1, MATRIX v2)
|
||||
{
|
||||
double angle, angles, sum;
|
||||
MATRIX v3 = NULL;
|
||||
int i;
|
||||
|
||||
angle = vectorDotProduct(v1, v2) / (vectorLength(v1) * vectorLength(v2));
|
||||
v3 = vectorCrossProduct(v1, v2);
|
||||
if (v3 != NULL) {
|
||||
angles = vectorLength(v3) / (vectorLength(v1) * vectorLength(v2));
|
||||
angle = Atan2d(angles, angle);
|
||||
for(i = 0, sum = .0; i < 3; i++){
|
||||
sum += v3[i][0];
|
||||
}
|
||||
if(sum < 0){
|
||||
angle *= -1.;
|
||||
}
|
||||
} else {
|
||||
angle = Acosd(angle);
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void scaleVector(MATRIX v, double scale)
|
||||
|
||||
Reference in New Issue
Block a user