Ejemplo n.º 1
0
Handle<Value> Transforms_Translate(const Arguments& args)
{
    HandleScope handle_scope;

    Transforms* ptr = GetPtr(args.This());
    assert(ptr);

    if (((args.Length() == 1) || (args.Length() == 2)) && isJSVector3(args[0]))
    {
        Vector3 d = fromJSVector3Unsafe(args[0]);

        Transforms::tTransformSpace relativeTo = Transforms::TS_LOCAL;
        if ((args.Length() == 2) && args[1]->IsUint32())
            relativeTo = (Transforms::tTransformSpace) args[1]->Uint32Value();

        ptr->translate(d, relativeTo);

        return Handle<Value>();
    }
    else if (((args.Length() == 3) || (args.Length() == 4)) &&
             args[0]->IsNumber() && args[1]->IsNumber() && args[2]->IsNumber())
    {
        Transforms::tTransformSpace relativeTo = Transforms::TS_LOCAL;
        if ((args.Length() == 4) && args[3]->IsUint32())
            relativeTo = (Transforms::tTransformSpace) args[3]->Uint32Value();

        ptr->translate(args[0]->NumberValue(), args[1]->NumberValue(), args[2]->NumberValue(), relativeTo);

        return Handle<Value>();
    }

    return ThrowException(String::New("Invalid parameters, syntax: translate(vector3 [, transform_space]) or translate(dx, dy, dz [, transform_space])"));
}
Ejemplo n.º 2
0
void Body::setWorldTransform(const btTransform& worldTrans)
{
    Transforms* pTransforms = getTransforms();
    if (pTransforms)
    {
        pTransforms->translate(fromBullet(worldTrans.getOrigin()) - pTransforms->getWorldPosition(), Transforms::TS_WORLD);

        if (m_bRotationEnabled)
            pTransforms->rotate(pTransforms->getWorldOrientation().rotationTo(fromBullet(worldTrans.getRotation())), Transforms::TS_WORLD);
    }
}
Ejemplo n.º 3
0
void transformCoiledCoil(AtomPointerVector& _chainA, AtomPointerVector& _chainB,double _zShiftA,double _zShiftB,double _crossingAngle, double _axialRotateA,double _axialRotateB,double _xShift,Transforms& _trans,CartesianPoint& _origin, CartesianPoint& _zAxis, CartesianPoint& _xAxis, AtomPointerVector& _axisA, AtomPointerVector& _axisB) {
	//====== Z Shift (Crossing Point) ======
	CartesianPoint zShiftACP(0.0, 0.0, _zShiftA);
	_trans.translate(_chainA, zShiftACP);

	CartesianPoint zShiftBCP(0.0, 0.0, _zShiftB);
	_trans.translate(_chainB, zShiftBCP);

	//===== Axial Rotation ======
	_trans.rotate(_chainA, _axialRotateA, _origin, _zAxis);
	_trans.rotate(_chainB, _axialRotateB, _origin, _zAxis);

	//====== Local Crossing Angle ======
	_trans.rotate(_chainA, (_crossingAngle/2.0), _origin, _xAxis);
	_trans.rotate(_axisA,  (_crossingAngle/2.0), _origin, _xAxis);

	_trans.rotate(_chainB, (_crossingAngle/2.0), _origin, _xAxis);
	_trans.rotate(_axisB,  (_crossingAngle/2.0), _origin, _xAxis);

	//====== X shift (Interhelical Distance) =======
	CartesianPoint interDistVect;
	interDistVect.setCoor((_xShift/2.0) * -1.0, 0.0, 0.0);
	_trans.translate(_chainA, interDistVect);
	_trans.translate(_axisA, interDistVect);

	interDistVect.setCoor((_xShift/2.0) * -1.0, 0.0, 0.0);
	_trans.translate(_chainB, interDistVect);
	_trans.translate(_axisB, interDistVect);

	// Rotation matrix for 180 degrees

	Matrix m(3,3,0.0);
	m[0][0] = -1.0;
	m[0][1] = 0.0;
	m[0][2] = 0.0;
	m[1][0] = 0.0;
	m[1][1] = -1.0;
	m[1][2] = 0.0;
	m[2][0] = 0.0;
	m[2][1] = 0.0;
	m[2][2] = 1.0;

	// Rotate chain B around Z axis
	Transforms trans; 
	trans.rotate(_chainB, m);
	trans.rotate(_axisB, m);

}
Ejemplo n.º 4
0
int main(int argc, char *argv[]){
	// Option Parser
	Options opt = setupOptions(argc,argv);
	Transforms tr;

	// Super-helical Radius Loop
	for (double sr = opt.superHelicalRadius[0]; sr <= opt.superHelicalRadius[1]; sr += opt.superHelicalRadius[2]){

		// Alpha-helical Phase Angle Loop
		for (double aph = opt.alphaHelicalPhaseAngle[0]; aph < opt.alphaHelicalPhaseAngle[1];aph+=opt.alphaHelicalPhaseAngle[2]){

		  // Super-helical Pitch Angle loop added by David Slochower
		  for(double shpa = opt.superHelicalPitchAngle[0]; shpa < opt.superHelicalPitchAngle[1]; shpa+=opt.superHelicalPitchAngle[2]) {
		    double shPitch = (2*M_PI*sr)/tan(M_PI*shpa/180);

			// Generate a coiled helix
			CoiledCoils cc;
			// Values used for previous work: cc.northCoiledCoils(sr, 1.5232, shPitch, 2.25, opt.numberOfResidues, 103.195, aph);
			// March 31, 2010: Jason Donald
			// Hard code values of h (rise/residue) = 1.51, r1 (alpha-helical radius), and theta (alpha helical frequency)
                        // based on median values observed by Gevorg Grigoryan
			//cc.northCoiledCoils(sr, 1.51, shPitch, 2.26, opt.numberOfResidues, 102.8, aph);
			
			AtomPointerVector coil = cc.getCoiledCoil(sr, 1.51, shPitch, 2.26, 102.8, aph, 0.0,opt.numberOfResidues); 

			// Apply symmetry operations to create a bundle
			int C_axis = atoi(opt.symmetry.substr(1,(opt.symmetry.length()-1)).c_str());
			if (opt.symmetry.substr(0,1) == "C"){
				Symmetry sym;
				sym.applyCN(coil,C_axis);
	
				// Write out bundle
				char filename[80];
				sprintf(filename, "%s_%s_%03d_%05.2f_%05.2f_shp%05.2f.pdb", opt.name.c_str(),opt.symmetry.c_str(),opt.numberOfResidues, sr, aph, shpa);
			
				cout << "Writing "<<filename<<endl;
				PDBWriter pout;
				pout.open(filename);
				pout.write(sym.getAtomPointers());
				pout.close();
			}	
			else if (opt.symmetry.substr(0,1) == "D"){
				// Z Rotate 
				for (double spa = opt.superHelicalPhaseAngle[0]; spa < opt.superHelicalPhaseAngle[1]; spa += opt.superHelicalPhaseAngle[2]){
					coil.clearSavedCoor();
					coil.saveCoor("preSPA");

					Matrix zRot = CartesianGeometry::getZRotationMatrix(spa);
					//coil.rotate(zRot);
					tr.rotate(coil, zRot);
					
					// Z Trans
					for (double ztrans = opt.d2zTranslation[0];ztrans < opt.d2zTranslation[1]; ztrans += opt.d2zTranslation[2]){
						coil.saveCoor("preZtrans");

						CartesianPoint z(0,0,ztrans);
						//coil.translate(z);
						tr.translate(coil, z);

						Symmetry sym;
						sym.applyDN(coil,C_axis);
								
						// Write out bundle
						char filename[80];
						sprintf(filename, "%s_%s_%03d_%05.2f_%05.2f_shp%05.2f_%05.2f_%05.2f.pdb", opt.name.c_str(),opt.symmetry.c_str(),opt.numberOfResidues,sr, aph, shpa, spa, ztrans);
			
						cout << "Writing "<<filename<<endl;
						PDBWriter pout;
						pout.open(filename);
						pout.write(sym.getAtomPointers());
						pout.close();

						coil.applySavedCoor("preZtrans");
					} // Ztrans
					coil.applySavedCoor("preSPA");
				} // SHA
			} 
                }
           }
	}
}