static REAL8 dEp4(REAL8 v, expnCoeffs *ak) { REAL8 energy, denergy, Energy, dEnergy, denom, x, y; x = v*v; energy = ep4(v, ak); y = sqrt(1.+energy); Energy = sqrt(1. + 2.* ak->eta * (y - 1.)) - 1.; denom = 1. + (ak->ePa1 + ak->ePa2) * x; denom = denom * denom; denergy = (1. + 2.*ak->ePa2*x + ((ak->ePa1 + ak->ePa2) * ak->ePa2 * x*x))/denom; dEnergy = - v * ak->eta * denergy /((1.+Energy) * y); return(dEnergy); }
void Bond::Render(Render2D * r) { double myangle, x1, y1, x2, y2, rise, run, lx, ly, cf = 0.02; QColor c1; if ( highlighted ) c1 = Render2D::highlightColor; else c1 = color; // for single bonds if ( order == 1 ) { if ( dashed > 0 ) r->drawLine( start->toQPoint(), end->toQPoint(), thick, c1, 1 ); else r->drawLine( start->toQPoint(), end->toQPoint(), thick, c1 ); return; } // for stereo_up bonds if ( order == 5 ) { r->drawUpLine( start->toQPoint(), end->toQPoint(), c1 ); return; } // for wavy bonds (order = 6) if ( order == 6 ) { r->drawWavyLine( start->toQPoint(), end->toQPoint(), c1 ); return; } // for stereo_down bonds if ( order == 7 ) { r->drawDownLine( start->toQPoint(), end->toQPoint(), c1 ); return; } // for double and triple bonds myangle = getAngle( start, end ); myangle += 90.0; myangle = myangle * ( M_PI / 180.0 ); //double offs = start->distanceTo(end) / 25.0; /* offs = preferences.getDoubleBondOffset(); if (order == 3) { if (thick > 2) offs += 0.5; if (thick > 3) offs += 0.4; if (thick > 4) offs += 0.3; } else { if (thick > 2) offs += 0.3; if (thick > 4) offs += 0.3; } x2 = cos(myangle) * 3.0 * offs; y2 = sin(myangle) * 3.0 * offs; // x1, y1, 3 and 4 are for use with special case 1 below x1 = cos(myangle) * 2.5 * offs; y1 = sin(myangle) * 2.5 * offs; */ /* original (does not use preferences!) double abl = 1.0; abl = (double)thick / 2.0 + 1.0; */ double abl = 1.0; abl = ( double ) thick / 2.0 + preferences.getDoubleBondOffset(); // check for order 2 special case (center double bond) bool special_case_1 = false; if ( order == 2 ) { //qDebug() << "start->element: " << start->element ; //qDebug() << "start->subst: " << start->substituents ; //qDebug() << "end->element: " << end->element ; //qDebug() << "end->subst: " << end->substituents ; if ( ( start->element == "O" ) && ( start->substituents == 2 ) ) special_case_1 = true; if ( ( end->element == "O" ) && ( end->substituents == 2 ) ) special_case_1 = true; if ( ( start->element == "C" ) && ( start->substituents == 2 ) ) special_case_1 = true; if ( ( end->element == "C" ) && ( end->substituents == 2 ) ) special_case_1 = true; if ( ( start->element == "CH2" ) && ( start->substituents == 2 ) ) special_case_1 = true; if ( ( end->element == "CH2" ) && ( end->substituents == 2 ) ) special_case_1 = true; if ( ( start->element == "N" ) && ( end->element == "N" ) ) special_case_1 = true; if ( wside == 2 ) // force centered double bond special_case_1 = true; } if ( special_case_1 ) abl = ( double ) thick / 2.0 + preferences.getDoubleBondOffset() / 4.0; else abl = ( double ) thick / 2.0 + preferences.getDoubleBondOffset() / 2.0; //qDebug() << "abl = " << abl; x2 = cos( myangle ) * abl; y2 = sin( myangle ) * abl; // x1, y1, 3 and 4 are for use with special case 1 below x1 = cos( myangle ) * abl; y1 = sin( myangle ) * abl; QPoint sp3( qRound( start->x + x1 ), qRound( start->y + y1 ) ); QPoint ep3( qRound( end->x + x1 ), qRound( end->y + y1 ) ); QPoint sp4( qRound( start->x - x1 ), qRound( start->y - y1 ) ); QPoint ep4( qRound( end->x - x1 ), qRound( end->y - y1 ) ); // shorten lines by removing from each end double bl = start->distanceTo( end ); if ( bl < 100.0 ) cf = 0.03; if ( bl < 51.0 ) cf = 0.05; if ( bl < 27.0 ) cf = 0.07; // find sp1 and ep1 rise = ( end->y + y2 ) - ( start->y + y2 ); run = ( end->x + x2 ) - ( start->x + x2 ); lx = start->x + x2 + run * cf; ly = start->y + y2 + rise * cf; QPoint sp1( ( int ) lx, ( int ) ly ); lx = start->x + x2 + run * ( 1.0 - cf ); ly = start->y + y2 + rise * ( 1.0 - cf ); QPoint ep1( ( int ) lx, ( int ) ly ); // find sp2 and ep2 rise = ( end->y - y2 ) - ( start->y - y2 ); run = ( end->x - x2 ) - ( start->x - x2 ); lx = start->x - x2 + run * cf; ly = start->y - y2 + rise * cf; QPoint sp2( ( int ) lx, ( int ) ly ); lx = start->x - x2 + run * ( 1.0 - cf ); ly = start->y - y2 + rise * ( 1.0 - cf ); QPoint ep2( ( int ) lx, ( int ) ly ); if ( special_case_1 == true ) { if ( dashed > 1 ) r->drawLine( sp3, ep3, thick, c1, 1 ); else r->drawLine( sp3, ep3, thick, c1 ); if ( dashed > 0 ) r->drawLine( sp4, ep4, thick, c1, 1 ); else r->drawLine( sp4, ep4, thick, c1 ); return; } QPoint sp, ep; if ( order == 2 ) { if ( wside == 1 ) { sp = sp1; ep = ep1; } else { sp = sp2; ep = ep2; } //qDebug() << "wside:" << wside; if ( dashed > 1 ) r->drawLine( start->toQPoint(), end->toQPoint(), thick, c1, 1 ); else r->drawLine( start->toQPoint(), end->toQPoint(), thick, c1 ); if ( dashed > 0 ) r->drawLine( sp, ep, thick, c1, 1 ); else r->drawLine( sp, ep, thick, c1 ); return; } if ( order == 3 ) { if ( dashed > 2 ) r->drawLine( start->toQPoint(), end->toQPoint(), thick, c1, 1 ); else r->drawLine( start->toQPoint(), end->toQPoint(), thick, c1 ); if ( dashed > 1 ) r->drawLine( sp1, ep1, thick, c1, 1 ); else r->drawLine( sp1, ep1, thick, c1 ); if ( dashed > 0 ) r->drawLine( sp2, ep2, thick, c1, 1 ); else r->drawLine( sp2, ep2, thick, c1 ); return; } }