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; }
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; }
/** * Write the table index for the next \a iLength pixels, starting from the \a iCount offset. * @param oBase Base image to encode. * @param iCount Current index in the image. * @param iLength Number of pixels to process. * @param pDest Destination to write to. */ static void WriteTableIndex(const Image32bpp &oBase, uint32 iCount, int iLength, Output *pDest) { while (iLength > 0) { uint32 iColour = oBase.Get(iCount); iCount++; uint8 biggest = GetR(iColour); if (biggest < GetG(iColour)) biggest = GetG(iColour); if (biggest < GetB(iColour)) biggest = GetB(iColour); pDest->Uint8(biggest); iLength--; } }
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; }
TSeqPos CSeq_bond::GetStop (ESeqLocExtremes /*ext*/) const { TSeqPos a = GetA().GetPoint(); if (!IsSetB()) { return a; } TSeqPos b = GetB().GetPoint(); return max(a, b); }
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; }
TerrainRenderer::PointF TerrainRenderer::GetBAround(const MapPoint pt, const unsigned char triangle, const unsigned char dir) { PointI ptNb = GetPointAround(PointI(pt), dir); Point<int> offset; MapPoint t = ConvertCoords(ptNb, &offset); return GetB(t, triangle) + PointF(offset); }
/** * Write the RGB colour for the next \a iLength pixels, starting from the \a iCount offset. * @param oBase Base image to encode. * @param iCount Current index in the image. * @param iLength Number of pixels to process. * @param pDest Destination to write to. */ static void WriteColour(const Image32bpp &oBase, uint32 iCount, int iLength, Output *pDest) { while (iLength > 0) { uint32 iColour = oBase.Get(iCount); iCount++; pDest->Uint8(GetR(iColour)); pDest->Uint8(GetG(iColour)); pDest->Uint8(GetB(iColour)); iLength--; } }
Color::operator RGBA() const { RGBA color; if(IsNullInstance()) Zero(color); else { color.r = GetR(); color.g = GetG(); color.b = GetB(); color.a = 255; } return color; }
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; }
void Color::Jsonize(JsonIO& jio) { int r, g, b; if(IsNullInstance()) { r = g = b = Null; } else { r = GetR(); g = GetG(); b = GetB(); } jio("red", r)("green", g)("blue", b); if(IsNull(r)) *this = Null; else *this = Color(r, g, b); }
BOOL Pipe::Save(PipePerisist *pPerisist) { InitAllData(); pPerisist->Key(GetKey()); pPerisist->Name(ms_Name.GetValue()); pPerisist->StartPtX(ms_StartPt.GetValue1()); pPerisist->StartPtY(ms_StartPt.GetValue2()); pPerisist->EndPtX(ms_EndPt.GetValue1()); pPerisist->EndPtY(ms_EndPt.GetValue2()); pPerisist->InJunID(ms_InJun.GetValue()); pPerisist->OutJunID(ms_OutJun.GetValue()); pPerisist->InDia(ms_InDia.GetValue()); pPerisist->InDiaUnit(ms_InDia.GetUnit()); pPerisist->Len(ms_Len.GetValue()); pPerisist->LenUnit(ms_Len.GetUnit()); pPerisist->WaveSpeed(ms_WaveSpeed.GetValue()); pPerisist->WaveSpeedUnit(ms_WaveSpeed.GetUnit()); pPerisist->Material(ms_Material.GetValue()); pPerisist->Size(ms_Size.GetValue()); pPerisist->PipeType(ms_PipeType.GetValue()); pPerisist->Thick(ms_Thick.GetValue()); pPerisist->ThickUnit(ms_Thick.GetUnit()); pPerisist->Elasticity(ms_Elasticity.GetValue()); pPerisist->ElasticityUnit(ms_Elasticity.GetUnit()); pPerisist->PossionRatio(ms_PossionRatio.GetValue()); pPerisist->InDiaReduce(ms_InDiaReduce.GetValue()); pPerisist->CalcWave(ms_CalcWave.GetValue()); pPerisist->SupportType(ms_SupportType.GetValue()); pPerisist->C1(ms_C1.GetValue()); pPerisist->FrictionModel(ms_LossType.GetValue()); pPerisist->Friction(ms_Friction.GetValue()); pPerisist->FrictionUnit(ms_Friction.GetUnit()); pPerisist->LocalK(ms_LocalK.GetValue()); pPerisist->PipeFactor(ms_PipeFactor.GetValue()); pPerisist->FitFactor(ms_FitFactor.GetValue()); pPerisist->InitFlow(ms_InitFlow.GetData()); pPerisist->SectionNum(ms_SectionNum.GetValue()); pPerisist->ParaNum(ms_ParaNum.GetValue()); pPerisist->PartFull(ms_PartFull.GetValue()); pPerisist->B(GetB()); return TRUE; }
void Color::Xmlize(XmlIO& xio) { int r, g, b; if(IsNullInstance()) { r = g = b = Null; } else { r = GetR(); g = GetG(); b = GetB(); } xio .Attr("red", r) .Attr("green", g) .Attr("blue", b) ; if(IsNull(r)) *this = Null; else *this = Color(r, g, b); }
void CVisualizerStatic::Draw() { const char STR[] = "0CC-FamiTracker"; // // // const size_t COUNT = std::size(STR); static long long t = 0; const auto FixRGB = [] (int x) { return MakeRGB(GetB(x), GetG(x), GetR(x)); }; const COLORREF Back[] = { FixRGB(FTEnv.GetSettings()->Appearance.iColBackground), FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite), FixRGB(FTEnv.GetSettings()->Appearance.iColBackgroundHilite2), }; const COLORREF Color = FixRGB(FTEnv.GetSettings()->Appearance.iColPatternText); const COLORREF Shadow = BlendColors(Color, 1, Back[0], 2); for (int y = m_iHeight - 1; y >= 0; --y) for (int x = m_iWidth - 1; x >= 0; --x) { int Dist = (abs(x - m_iWidth / 2) + abs(y - m_iHeight / 2) - t / 5) % 12; if (Dist < 0) Dist += 12; m_pBlitBuffer[y * m_iWidth + x] = Back[Dist / 4]; } for (size_t i = 0; i < COUNT; ++i) { double Phase = .07 * t - .9 * i; double x = sin(Phase) * 2. + m_iWidth + 11. * i - .4 * t; double y = sin(Phase) * 7.; const double MAX = m_iWidth + 120.; if (x < 0) { x = fmod(x, MAX); if (x < -40.) x += MAX; } DrawChar(STR[i], static_cast<int>(x) + 1, static_cast<int>(m_iHeight / 2. - 3.5 - y) + 1, Shadow); DrawChar(STR[i], static_cast<int>(x), static_cast<int>(m_iHeight / 2. - 3.5 - y), Color); } ++t; }
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; }
/// Erzeugt die Dreiecke für die Ränder void TerrainRenderer::UpdateBorderTrianglePos(const MapPoint pt, const GameWorldViewer& gwv, const bool update) { unsigned int pos = GetVertexIdx(pt); // Für VBO-Aktualisierung: // Erzeugte Ränder zählen unsigned count_borders = 0; // Erstes Offset merken unsigned first_offset = 0; // Rand links - rechts for(unsigned char i = 0; i < 2; ++i) { if(!borders[pos].left_right[i]) continue; unsigned int offset = borders[pos].left_right_offset[i]; if(!first_offset) first_offset = offset; gl_vertices[offset][i ? 0 : 2] = GetTerrain(pt); gl_vertices[offset][1 ] = GetTerrainAround(pt, 4); gl_vertices[offset][i ? 2 : 0] = GetB(pt, i); ++count_borders; } // Rand rechts - links for(unsigned char i = 0; i < 2; ++i) { if(!borders[pos].right_left[i]) continue; unsigned int offset = borders[pos].right_left_offset[i]; if(!first_offset) first_offset = offset; gl_vertices[offset][i ? 2 : 0] = GetTerrainAround(pt, 4); gl_vertices[offset][1 ] = GetTerrainAround(pt, 3); if(i == 0) gl_vertices[offset][2] = GetB(pt, 1); else gl_vertices[offset][0] = GetBAround(pt, 0, 3); ++count_borders; } // Rand oben - unten for(unsigned char i = 0; i < 2; ++i) { if(!borders[pos].top_down[i]) continue; unsigned int offset = borders[pos].top_down_offset[i]; if(!first_offset) first_offset = offset; gl_vertices[offset][i ? 2 : 0] = GetTerrainAround(pt, 5); gl_vertices[offset][1 ] = GetTerrainAround(pt, 4); if(i == 0) gl_vertices[offset][2] = GetB(pt, i); else gl_vertices[offset][0] = GetBAround(pt, i, 5); //x - i + i * rt, y + i, i ++count_borders; } /// Bei Vertexbuffern das die Daten aktualisieren if(update && vboBuffersUsed) { glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo_vertices); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, first_offset * sizeof(Triangle), count_borders * sizeof(Triangle), &gl_vertices[first_offset]); } }