int ShadedSurfaceLayer::DrawTriangle(float x1, float y1, float z1, int c1, float x2, float y2, float z2, int c2, float x3, float y3, float z3, int c3) const { int retval = NVN_NOERR; float ux, uy, uz; float vx, vy, vz; ux = x2 - x1; vx = x3 - x1; uy = y2 - y1; vy = y3 - y1; uz = z2 - z1; vz = z3 - z1; glNormal3f(uy*vz - uz*vy, uz*vx - ux*vz, ux*vy - uy*vx); glColor4ub(GetR(c1), GetG(c1), GetB(c1), GetA(c1)); glVertex3f(x1, y1, z1); glColor4ub(GetR(c2), GetG(c2), GetB(c2), GetA(c2)); glVertex3f(x2, y2, z2); glColor4ub(GetR(c3), GetG(c3), GetB(c3), GetA(c3)); glVertex3f(x3, y3, z3); }
wxSVGMatrix wxSVGMatrix::Multiply(const wxSVGMatrix& secondMatrix) const { wxSVGMatrix res; res.SetA(GetA() * secondMatrix.GetA() + GetC() * secondMatrix.GetB()); res.SetB(GetB() * secondMatrix.GetA() + GetD() * secondMatrix.GetB()); res.SetC(GetA() * secondMatrix.GetC() + GetC() * secondMatrix.GetD()); res.SetD(GetB() * secondMatrix.GetC() + GetD() * secondMatrix.GetD()); res.SetE(GetA() * secondMatrix.GetE() + GetC() * secondMatrix.GetF() + GetE()); res.SetF(GetB() * secondMatrix.GetE() + GetD() * secondMatrix.GetF() + GetF()); return res; }
wxSVGMatrix wxSVGMatrix::Inverse() const { wxSVGMatrix res; double d = 1.0 / (GetA() * GetD() - GetB() * GetC()); res.SetA(GetD() * d); res.SetB(-GetB() * d); res.SetC(-GetC() * d); res.SetD(GetA() * d); res.SetE(-GetE() * res.GetA() - GetF() * res.GetC()); res.SetF(-GetE() * res.GetB() - GetF() * res.GetD()); return res; }
/** * Look ahead in the base image to check how many pixels from the current position have the same opacity. * @param iCount Current index in the image. * @param iEndCount End of the image. * @parswm oBase Base image. * @return Number of pixels to go before the opacity of the current pixel changes (limited to 63 look ahead). */ static int GetDistanceToNextTransparency(const uint32 iCount, const uint32 iEndCount, const Image32bpp &oBase) { uint32 iLength = iEndCount - iCount; if (iLength > 63) iLength = 63; // No need to look ahead further. uint8 iOpacity = GetA(oBase.Get(iCount)); for (uint i = 1; i < iLength; i++) { if (iOpacity != GetA(oBase.Get(iCount + i))) return i; } return iLength; }
bool CSeq_bond::IsSetStrand(EIsSetStrand flag) const { switch (flag) { case eIsSetStrand_Any: return GetA().IsSetStrand() || (IsSetB() && GetB().IsSetStrand()); case eIsSetStrand_All: return GetA().IsSetStrand() && IsSetB() && GetB().IsSetStrand(); } return false; }
void O3QuadraticEquation<TYPE>::GetXIntercepts(double* r1, double* r2, const double x) const { double a=GetA(), b=GetB(), c=GetC()-x; double sqrt_b2_minus_4ac = sqrt((b*b)-(4*a*c)); double recip_2a = O3recip(2*a); if (r1) *r1 = (-b + sqrt_b2_minus_4ac) * recip_2a; if (r2) *r2 = (-b - sqrt_b2_minus_4ac) * recip_2a; }
ENa_strand CSeq_bond::GetStrand(void) const { ENa_strand a_strand = GetA().IsSetStrand() ? GetA().GetStrand() : eNa_strand_unknown; ENa_strand b_strand = eNa_strand_unknown; if (IsSetB() && GetB().IsSetStrand()) { b_strand = GetB().GetStrand(); } if (a_strand == eNa_strand_unknown && b_strand != eNa_strand_unknown) { a_strand = b_strand; } else if (a_strand != eNa_strand_unknown && b_strand == eNa_strand_unknown ) { b_strand = a_strand; } return (a_strand != b_strand) ? eNa_strand_other : a_strand; }
/** * Encode a 32bpp image from the \a oBase image, and optionally the recolouring \a pLayer bitmap. */ static void Encode32bpp(int iWidth, int iHeight, const Image32bpp &oBase, const Image8bpp *pLayer, Output *pDest, const unsigned char *pNumber) { const uint32 iPixCount = iWidth * iHeight; uint32 iCount = 0; while (iCount < iPixCount) { int iLength = GetDistanceToNextRecolour(iCount, iPixCount, pLayer); int length2 = GetDistanceToNextTransparency(iCount, iPixCount, oBase); if (iLength > 63) iLength = 63; if (iLength == 0) { // Recolour layer. uint8 iTableNumber; iLength = GetRecolourInformation(iCount, iPixCount, pLayer, &iTableNumber); if (length2 < iLength) iLength = length2; assert(iLength > 0); pDest->Uint8(64 + 128 + iLength); pDest->Uint8(pNumber[iTableNumber]); pDest->Uint8(GetA(oBase.Get(iCount))); // Opacity. WriteTableIndex(oBase, iCount, iLength, pDest); iCount += iLength; continue; } if (length2 < iLength) iLength = length2; assert(iLength > 0); uint8 iOpacity = GetA(oBase.Get(iCount)); if (iOpacity == OP_OPAQUE) { // Fixed non-transparent 32bpp pixels (RGB). pDest->Uint8(iLength); WriteColour(oBase, iCount, iLength, pDest); iCount += iLength; continue; } if (iOpacity == OP_TRANSPARENT) { // Fixed fully transparent pixels. pDest->Uint8(128 + iLength); iCount += iLength; continue; } /* Partially transparent 32bpp pixels (RGB). */ pDest->Uint8(64 + iLength); pDest->Uint8(iOpacity); WriteColour(oBase, iCount, iLength, pDest); iCount += iLength; continue; } }
Double_t KVRecombination::Invert(Double_t energy){ //Given the PHD (in MeV) of a particle of charge Z and mass A //(set using SetZandA() method), this method inverts the Parlog formula //in order to find the energy loss of the particle in the detector. const_cast<KVRecombination*>(this)->GetParlogPHDFunction(GetZ(),GetA()); Double_t xmin, xmax; fParlog->GetRange(xmin,xmax); return fParlog->GetX(energy,xmin,xmax); }
LLBC_MD5::MD5GroupDigest &LLBC_MD5::MD5GroupDigest::operator +=(const LLBC_MD5::MD5GroupDigest &right) { SetA(GetA() + right.GetA()); SetB(GetB() + right.GetB()); SetC(GetC() + right.GetC()); SetD(GetD() + right.GetD()); return *this; }
TSeqPos CSeq_bond::GetStop (ESeqLocExtremes /*ext*/) const { TSeqPos a = GetA().GetPoint(); if (!IsSetB()) { return a; } TSeqPos b = GetB().GetPoint(); return max(a, b); }
//----------------------------------------------------------------------------- // // CloudP series // //----------------------------------------------------------------------------- void mglGraph::AVertex(mreal x,mreal y,mreal z, mreal a,mreal alpha) { mglColor c; if(!ScalePoint(x,y,z) || isnan(a)) return; a = GetA(a); if(OnCoord) c = GetC(x,y,z); else c = GetC(a,false); a = alpha>0 ? (a+1)*(a+1)/4 : -(a-1)*(a-1)/4; // a = alpha>0 ? (a+1)/2 : (a-1)/2; if(a) Ball(x,y,z,c,-alpha*a); }
Double_t KVRecombination::Compute(Double_t energy) const{ //Calculate the pulse height defect (in MeV) for a given energy loss in the detector, //a given Z and a given A (Z and A of the particle should be set first using method SetZandA) //The Parlog formula is used: // // PHD(E) = 1/2 * Ed *( 1-1/X * ln|1+X| + X * ln|1+1/X| ) // with X = a*A*Z**2/Ed // Ed = energy lost by particle in detector (=E if particle stops) return const_cast<KVRecombination*>(this)->GetParlogPHDFunction(GetZ(),GetA())->Eval(energy); }
OBUnitCell::LatticeType OBUnitCell::GetLatticeType() const { if (_lattice != Undefined) return _lattice; else if (_spaceGroup != NULL) return GetLatticeType(_spaceGroup->GetId()); double a = GetA(); double b = GetB(); double c = GetC(); double alpha = GetAlpha(); double beta = GetBeta(); double gamma = GetGamma(); unsigned int rightAngles = 0; if (IsApprox(alpha, 90.0, 1.0e-3)) rightAngles++; if (IsApprox(beta, 90.0, 1.0e-3)) rightAngles++; if (IsApprox(gamma, 90.0, 1.0e-3)) rightAngles++; // recast cache member "_lattice" as mutable OBUnitCell::LatticeType *lattice = const_cast<OBUnitCell::LatticeType*>(&_lattice); switch (rightAngles) { case 3: if (IsApprox(a, b, 1.0e-4) && IsApprox(b, c, 1.0e-4)) *lattice = Cubic; else if (IsApprox(a, b, 1.0e-4) || IsApprox(b, c, 1.0e-4)) *lattice = Tetragonal; else *lattice = Orthorhombic; break; case 2: if ( (IsApprox(alpha, 120.0, 1.0e-3) || IsApprox(beta, 120.0, 1.0e-3) || IsApprox(gamma, 120.0f, 1.0e-3)) && (IsApprox(a, b, 1.0e-4) || IsApprox(b, c, 1.0e-4)) ) *lattice = Hexagonal; else *lattice = Monoclinic; break; default: if (IsApprox(a, b, 1.0e-4) && IsApprox(b, c, 1.0e-4)) *lattice = Rhombohedral; else *lattice = Triclinic; } return *lattice; }
double GetBraces(AppCtx* context, PetscScalar* solution, HClusteredNet netIdx) { double A = GetA(context, netIdx); double secondTerm = 0.0; HClusteredNetWrapper netIdxW = (*context->hd)[netIdx]; for (int sinkIdx = 1; sinkIdx < netIdxW.clusterIdxs()->size(); sinkIdx++) { double Ci = GetCi(context, netIdx, sinkIdx); double Doi = GetDoi(context, solution, netIdx, sinkIdx); secondTerm += Ci * Doi; } secondTerm *= 0.5; return A + secondTerm; }
double O3QuadraticEquation<TYPE>::GetHighXIntercept(const double x) const { double a=GetA(), b=GetB(), c=GetC()-x; double sqrt_b2_minus_4ac = sqrt((b*b)-(4*a*c)); double recip_2a = O3recip(2*a); return (-b - sqrt_b2_minus_4ac) * recip_2a; }
//----------------------------------------------------------------------------- // // Surf3A series // //----------------------------------------------------------------------------- void mglGraph::Surf3A(mreal val, const mglData &x, const mglData &y, const mglData &z, const mglData &a, const mglData &b, const char *sch) { long i,j,k,i0,i1,n=a.nx,m=a.ny,l=a.nz; long *kx1,*kx2,*ky1,*ky2,*kz,pc; bool both, wire = sch && strchr(sch,'#'); mreal *pp=0,*cc=0,*kk=0,*nn=0; mreal d,xx,yy,zz,nx,ny,nz,dx,dy,dz,tx,ty,tz,alpha; if(n<2 || m<2 || l<2) { SetWarn(mglWarnLow,"Surf3A"); return; } both = x.nx*x.ny*x.nz==n*m*l && y.nx*y.ny*y.nz==n*m*l && z.nx*z.ny*z.nz==n*m*l; if(!(both || (x.nx==n && y.nx==m && z.nx==l))) { SetWarn(mglWarnDim,"Surf3A"); return; } if(b.nx*b.ny*b.nz!=n*m*l) { SetWarn(mglWarnDim,"Surf3A"); return; } static int cgid=1; StartGroup("Surf3A",cgid++); bool inv = (sch && strchr(sch,'-')); SetScheme(sch); kx1 = new long[n*m]; kx2 = new long[n*m]; ky1 = new long[n*m]; ky2 = new long[n*m]; kz = new long[n*m]; Pal[100]=GetC(val); // DefColor(c,AlphaDef); for(k=0;k<l;k++) { memcpy(kx1,kx2,n*m*sizeof(long)); memset(kx2,-1,n*m*sizeof(long)); memcpy(ky1,ky2,n*m*sizeof(long)); memset(ky2,-1,n*m*sizeof(long)); memset(kz ,-1,n*m*sizeof(long)); for(i=0;i<n;i++) for(j=0;j<m;j++) { i1 = i+n*j; i0 = i1+n*m*k; if(i<n-1) { d = _d(val,a.a[i0],a.a[i0+1]); if(d>=0 && d<1) { xx = both ? x.a[i0]*(1.-d)+x.a[i0+1]*d : x.a[i]*(1.-d)+x.a[i+1]*d; yy = both ? y.a[i0]*(1.-d)+y.a[i0+1]*d : y.a[j]; zz = both ? z.a[i0]*(1.-d)+z.a[i0+1]*d : z.a[k]; alpha = b.a[i0]*(1.-d)+b.a[i0+1]*d; normal_3d(a,i+d,j,k,&dx,&dy,&dz,inv); if(both) { normal_3d(x,i+d,j,k,&tx,&ty,&tz,true); nx = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(y,i+d,j,k,&tx,&ty,&tz,true); ny = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(z,i+d,j,k,&tx,&ty,&tz,true); nz = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); } else { normal_1d(x,i+d,&tx,true); nx = dx/tx; normal_1d(y,j,&ty,true); ny = dy/ty; normal_1d(z,k,&tz,true); nz = dz/tz; } kx2[i1] = add_spoint(pc,&pp,&kk,&cc,&nn,xx,yy,zz,nx,ny,nz, i+d,j,k,(GetA(alpha)+1)*(GetA(alpha)+1)/4); } } if(j<m-1) { d = _d(val,a.a[i0],a.a[i0+n]); if(d>=0 && d<1) { xx = both ? x.a[i0]*(1.-d)+x.a[i0+n]*d : x.a[i]; yy = both ? y.a[i0]*(1.-d)+y.a[i0+n]*d : y.a[j]*(1.-d)+y.a[j+1]*d; zz = both ? z.a[i0]*(1.-d)+z.a[i0+n]*d : z.a[k]; alpha = b.a[i0]*(1.-d)+b.a[i0+n]*d; normal_3d(a,i,j+d,k,&dx,&dy,&dz,inv); if(both) { normal_3d(x,i,j+d,k,&tx,&ty,&tz,true); nx = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(y,i,j+d,k,&tx,&ty,&tz,true); ny = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(z,i,j+d,k,&tx,&ty,&tz,true); nz = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); } else { normal_1d(x,i,&tx,true); nx = dx/tx; normal_1d(y,j+d,&ty,true); ny = dy/ty; normal_1d(z,k,&tz,true); nz = dz/tz; } ky2[i1] = add_spoint(pc,&pp,&kk,&cc,&nn,xx,yy,zz,nx,ny,nz, i,j+d,k,(GetA(alpha)+1)*(GetA(alpha)+1)/4); } } if(k>0) { d = _d(val,a.a[i0-n*m],a.a[i0]); if(d>=0 && d<1) { xx = both ? x.a[i0-n*m]*(1.-d)+x.a[i0]*d : x.a[i]; yy = both ? y.a[i0-n*m]*(1.-d)+y.a[i0]*d : y.a[j]; zz = both ? z.a[i0-n*m]*(1.-d)+z.a[i0]*d : z.a[k-1]*(1.-d)+z.a[k]*d; alpha = b.a[i0-n*m]*(1.-d)+b.a[i0]*d; normal_3d(a,i,j,k+d-1,&dx,&dy,&dz,inv); if(both) { normal_3d(x,i,j,k+d-1,&tx,&ty,&tz,true); nx = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(y,i,j,k+d-1,&tx,&ty,&tz,true); ny = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); normal_3d(z,i,j,k+d-1,&tx,&ty,&tz,true); nz = (dx*tx+dy*ty+dz*tz)/(tx*tx+ty*ty+tz*tz); } else { normal_1d(x,i,&tx,true); nx = dx/tx; normal_1d(y,j,&ty,true); ny = dy/ty; normal_1d(z,k+d-1,&tz,true); nz = dz/tz; } kz[i1] = add_spoint(pc,&pp,&kk,&cc,&nn,xx,yy,zz,nx,ny,nz, i,j,k+d-1,(GetA(alpha)+1)*(GetA(alpha)+1)/4); } } } if(k>0) surf3_plot(n,m,kx1,kx2,ky1,ky2,kz,pp,cc,kk,nn,wire); } EndGroup(); delete []kx1; delete []kx2; delete []ky1; delete []ky2; delete []kz; if(pp) { free(pp); free(kk); free(cc); free(nn); } }
A():B(1),a(GetA()) { printf("%s,%d\n",__FUNCTION__,__LINE__); }