+ for (i=0;i<_number_of_parts;i++)
+ {
+ Rotorpart* rp = getRotorpart(i);
+ float lpos[3],lforceattac[3],lspeed[3],dirzentforce[3];
+ float s = Math::sin(2*pi*i/_number_of_parts);
+ float c = Math::cos(2*pi*i/_number_of_parts);
+ float sp = Math::sin(float(2*pi*i/_number_of_parts-pi/2.+_phi));
+ float cp = Math::cos(float(2*pi*i/_number_of_parts-pi/2.+_phi));
+ float direction[3],nextdirection[3],help[3],direction90deg[3];
+ float rotorpartmass = _weight_per_blade*_number_of_blades/_number_of_parts*.453;
+ float speed=_rotor_rpm/60*_diameter*_rel_blade_center*pi;
+ float lentocenter=_diameter*_rel_blade_center*0.5;
+ float lentoforceattac=_diameter*_rel_len_hinge*0.5;
+ float zentforce=rotorpartmass*speed*speed/lentocenter;
+
+ Math::mul3(c ,directions[0],help);
+ Math::mul3(s ,directions[1],direction);
+ Math::add3(help,direction,direction);
+
+ Math::mul3(c ,directions[1],help);
+ Math::mul3(s ,directions[2],direction90deg);
+ Math::add3(help,direction90deg,direction90deg);
+
+ Math::mul3(cp ,directions[1],help);
+ Math::mul3(sp ,directions[2],nextdirection);
+ Math::add3(help,nextdirection,nextdirection);
+
+ Math::mul3(lentocenter,direction,lpos);
+ Math::add3(lpos,_base,lpos);
+ Math::mul3(lentoforceattac,nextdirection,lforceattac);
+ //nextdirection: +90deg (gyro)!!!
+
+ Math::add3(lforceattac,_base,lforceattac);
+ Math::mul3(speed,direction90deg,lspeed);
+ Math::mul3(1,nextdirection,dirzentforce);
+ rp->setPosition(lpos);
+ rp->setNormal(_normal);
+ rp->setZentipetalForce(zentforce);
+ rp->setPositionForceAttac(lforceattac);
+ rp->setSpeed(lspeed);
+ rp->setDirectionofZentipetalforce(dirzentforce);
+ rp->setDirectionofRotorPart(direction);
+ }
+#undef _base
+#undef _forward
+#undef _normal
+ _directions_and_postions_dirty=false;
+}
+
+void Rotor::compile()
+{
+ // Have we already been compiled?
+ if(_rotorparts.size() != 0) return;
+
+ //rotor is divided into _number_of_parts parts
+ //each part is calcualted at _number_of_segments points
+
+ //clamp to 4..256
+ //and make it a factor of 4
+ _number_of_parts=(int(Math::clamp(_number_of_parts,4,256))>>2)<<2;
+
+ _dynamic=_dynamic*(1/ //inverse of the time
+ ( (60/_rotor_rpm)/4 //for rotating 90 deg
+ +(60/_rotor_rpm)/(2*_number_of_blades) //+ meantime a rotorblade
+ //will pass a given point
+ ));
+ //normalize the directions
+ Math::unit3(_forward,_forward);
+ Math::unit3(_normal,_normal);
+ _num_ground_contact_pos=(_number_of_parts<16)?_number_of_parts:16;