1 #include <simgear/debug/logstream.hxx>
5 #include "Rotorpart.hpp"
6 #include "Rotorblade.hpp"
12 SG_USING_STD(setprecision);
19 const float pi=3.14159;
35 _base[0] = _base[1] = _base[2] = 0;
42 _force_at_max_pitch=0;
45 _forward[1]=_forward[2]=0;
46 _max_pitch=13./180*pi;
47 _maxcyclicail=10./180*pi;
48 _maxcyclicele=10./180*pi;
50 _mincyclicail=-10./180*pi;
51 _mincyclicele=-10./180*pi;
52 _min_pitch=-.5/180*pi;
54 _normal[0] = _normal[1] = 0;
57 _omega=_omegan=_omegarel=0;
64 _rellenteeterhinge=0.01;
78 for(i=0; i<_rotorparts.size(); i++) {
79 Rotorpart* r = (Rotorpart*)_rotorparts.get(i);
82 for(i=0; i<_rotorblades.size(); i++) {
83 Rotorblade* r = (Rotorblade*)_rotorblades.get(i);
89 void Rotor::inititeration(float dt)
91 if ((_engineon)&&(_omegarel>=1)) return;
92 if ((!_engineon)&&(_omegarel<=0)) return;
93 _omegarel+=dt*1/5.*(_engineon?1:-1); //hier 30
94 _omegarel=Math::clamp(_omegarel,0,1);
95 _omega=_omegan*_omegarel;
97 for(i=0; i<_rotorparts.size(); i++) {
98 Rotorpart* r = (Rotorpart*)_rotorparts.get(i);
101 for(i=0; i<_rotorblades.size(); i++) {
102 Rotorblade* r = (Rotorblade*)_rotorblades.get(i);
107 int Rotor::getValueforFGSet(int j,char *text,float *f)
109 if (_name[0]==0) return 0;
114 if (!numRotorblades()) return 0;
117 sprintf(text,"/rotors/%s/cone", _name);
119 *f=( ((Rotorblade*)getRotorblade(0))->getFlapatPos(0)
120 +((Rotorblade*)getRotorblade(0))->getFlapatPos(1)
121 +((Rotorblade*)getRotorblade(0))->getFlapatPos(2)
122 +((Rotorblade*)getRotorblade(0))->getFlapatPos(3)
129 sprintf(text,"/rotors/%s/roll", _name);
131 *f=( ((Rotorblade*)getRotorblade(0))->getFlapatPos(1)
132 -((Rotorblade*)getRotorblade(0))->getFlapatPos(3)
138 sprintf(text,"/rotors/%s/yaw", _name);
140 *f=( ((Rotorblade*)getRotorblade(0))->getFlapatPos(2)
141 -((Rotorblade*)getRotorblade(0))->getFlapatPos(0)
147 sprintf(text,"/rotors/%s/rpm", _name);
156 if (b>=numRotorblades()) return 0;
158 sprintf(text,"/rotors/%s/blade%i_%s",
160 w==0?"pos":(w==1?"flap":"incidence"));
161 if (w==0) *f=((Rotorblade*)getRotorblade(b))->getPhi()*180/pi;
162 else if (w==1) *f=((Rotorblade*) getRotorblade(b))->getrealAlpha()*180/pi;
163 else *f=((Rotorblade*)getRotorblade(b))->getIncidence()*180/pi;
169 if (4!=numRotorparts()) return 0; //compile first!
172 sprintf(text,"/rotors/%s/cone", _name);
173 *f=( ((Rotorpart*)getRotorpart(0))->getrealAlpha()
174 +((Rotorpart*)getRotorpart(1))->getrealAlpha()
175 +((Rotorpart*)getRotorpart(2))->getrealAlpha()
176 +((Rotorpart*)getRotorpart(3))->getrealAlpha()
182 sprintf(text,"/rotors/%s/roll", _name);
183 *f=( ((Rotorpart*)getRotorpart(0))->getrealAlpha()
184 -((Rotorpart*)getRotorpart(2))->getrealAlpha()
185 )/2*180/pi*(_ccw?-1:1);
190 sprintf(text,"/rotors/%s/yaw", _name);
191 *f=( ((Rotorpart*)getRotorpart(1))->getrealAlpha()
192 -((Rotorpart*)getRotorpart(3))->getrealAlpha()
198 sprintf(text,"/rotors/%s/rpm", _name);
205 if (b>=_number_of_blades) return 0;
207 sprintf(text,"/rotors/%s/blade%i_%s",
209 w==0?"pos":(w==1?"flap":"incidence"));
210 *f=((Rotorpart*)getRotorpart(0))->getPhi()*180/pi+360*b/_number_of_blades*(_ccw?1:-1);
221 rl=Math::sqr(Math::sin(rl*pi/2));
222 rk=Math::sqr(Math::sin(rk*pi/2));
224 if(w==2) {k+=2;l+=2;}
226 if(w==1) {k+=1;l+=1;}
229 if (w==1) *f=rk*((Rotorpart*) getRotorpart(k))->getrealAlpha()*180/pi
230 +rl*((Rotorpart*) getRotorpart(l))->getrealAlpha()*180/pi;
231 else if(w==2) *f=rk*((Rotorpart*)getRotorpart(k))->getIncidence()*180/pi
232 +rl*((Rotorpart*)getRotorpart(l))->getIncidence()*180/pi;
238 void Rotor::setEngineOn(int value)
243 void Rotor::setAlpha0(float f)
247 void Rotor::setAlphamin(float f)
251 void Rotor::setAlphamax(float f)
255 void Rotor::setAlpha0factor(float f)
261 int Rotor::numRotorparts()
263 return _rotorparts.size();
266 Rotorpart* Rotor::getRotorpart(int n)
268 return ((Rotorpart*)_rotorparts.get(n));
270 int Rotor::numRotorblades()
272 return _rotorblades.size();
275 Rotorblade* Rotor::getRotorblade(int n)
277 return ((Rotorblade*)_rotorblades.get(n));
280 void Rotor::strncpy(char *dest,const char *src,int maxlen)
283 while(src[n]&&n<(maxlen-1))
293 void Rotor::setNormal(float* normal)
296 float invsum,sqrsum=0;
297 for(i=0; i<3; i++) { sqrsum+=normal[i]*normal[i];}
300 invsum=1/Math::sqrt(sqrsum);
303 for(i=0; i<3; i++) { _normal[i] = normal[i]*invsum; }
306 void Rotor::setForward(float* forward)
309 float invsum,sqrsum=0;
310 for(i=0; i<3; i++) { sqrsum+=forward[i]*forward[i];}
313 invsum=1/Math::sqrt(sqrsum);
316 for(i=0; i<3; i++) { _forward[i] = forward[i]*invsum; }
320 void Rotor::setForceAtPitchA(float force)
322 _force_at_pitch_a=force;
324 void Rotor::setPowerAtPitch0(float value)
326 _power_at_pitch_0=value;
328 void Rotor::setPowerAtPitchB(float value)
330 _power_at_pitch_b=value;
332 void Rotor::setPitchA(float value)
334 _pitch_a=value/180*pi;
336 void Rotor::setPitchB(float value)
338 _pitch_b=value/180*pi;
340 void Rotor::setBase(float* base)
343 for(i=0; i<3; i++) _base[i] = base[i];
347 void Rotor::setMaxCyclicail(float value)
349 _maxcyclicail=value/180*pi;
351 void Rotor::setMaxCyclicele(float value)
353 _maxcyclicele=value/180*pi;
355 void Rotor::setMinCyclicail(float value)
357 _mincyclicail=value/180*pi;
359 void Rotor::setMinCyclicele(float value)
361 _mincyclicele=value/180*pi;
363 void Rotor::setMinCollective(float value)
365 _min_pitch=value/180*pi;
367 void Rotor::setMaxCollective(float value)
369 _max_pitch=value/180*pi;
371 void Rotor::setDiameter(float value)
375 void Rotor::setWeightPerBlade(float value)
377 _weight_per_blade=value;
379 void Rotor::setNumberOfBlades(float value)
381 _number_of_blades=int(value+.5);
383 void Rotor::setRelBladeCenter(float value)
385 _rel_blade_center=value;
387 void Rotor::setDynamic(float value)
391 void Rotor::setDelta3(float value)
395 void Rotor::setDelta(float value)
399 void Rotor::setTranslift(float value)
403 void Rotor::setC2(float value)
407 void Rotor::setStepspersecond(float steps)
409 _stepspersecond=steps;
411 void Rotor::setRPM(float value)
415 void Rotor::setRelLenHinge(float value)
417 _rel_len_hinge=value;
420 void Rotor::setAlphaoutput(int i, const char *text)
422 //printf("SetAlphaoutput %i [%s]\n",i,text);
423 strncpy(_alphaoutput[i],text,255);
425 void Rotor::setName(const char *text)
427 strncpy(_name,text,128);//128: some space needed for settings
430 void Rotor::setCcw(int ccw)
434 void Rotor::setNotorque(int value)
438 void Rotor::setSimBlades(int value)
443 void Rotor::setRelLenTeeterHinge(float f)
445 _rellenteeterhinge=f;
447 void Rotor::setTeeterdamp(float f)
451 void Rotor::setMaxteeterdamp(float f)
459 void Rotor::setCollective(float lval)
461 lval = Math::clamp(lval, -1, 1);
463 //printf("col: %5.3f\n",lval);
464 for(i=0; i<_rotorparts.size(); i++) {
465 ((Rotorpart*)_rotorparts.get(i))->setCollective(lval);
468 float col=_min_pitch+(lval+1)/2*(_max_pitch-_min_pitch);
469 for(i=0; i<_rotorblades.size(); i++) {
470 ((Rotorblade*)_rotorblades.get(i))->setCollective(col);
474 void Rotor::setCyclicele(float lval,float rval)
476 rval = Math::clamp(rval, -1, 1);
477 lval = Math::clamp(lval, -1, 1);
478 float col=_mincyclicele+(lval+1)/2*(_maxcyclicele-_mincyclicele);
480 for(i=0; i<_rotorblades.size(); i++) {
481 //((Rotorblade*)_rotorblades.get(i))->setCyclicele(col*Math::sin(((Rotorblade*)_rotorblades.get(i))->getPhi()));
482 ((Rotorblade*)_rotorblades.get(i))->setCyclicele(col);
484 if (_rotorparts.size()!=4) return;
485 //printf(" ele: %5.3f %5.3f\n",lval,rval);
486 ((Rotorpart*)_rotorparts.get(1))->setCyclic(lval);
487 ((Rotorpart*)_rotorparts.get(3))->setCyclic(-lval);
489 void Rotor::setCyclicail(float lval,float rval)
491 lval = Math::clamp(lval, -1, 1);
492 rval = Math::clamp(rval, -1, 1);
493 float col=_mincyclicail+(lval+1)/2*(_maxcyclicail-_mincyclicail);
495 for(i=0; i<_rotorblades.size(); i++) {
496 ((Rotorblade*)_rotorblades.get(i))->setCyclicail(col);
498 if (_rotorparts.size()!=4) return;
499 //printf("ail: %5.3f %5.3f\n",lval,rval);
501 ((Rotorpart*)_rotorparts.get(0))->setCyclic(-lval);
502 ((Rotorpart*)_rotorparts.get(2))->setCyclic( lval);
506 float Rotor::getGroundEffect(float* posOut)
510 for(i=0; i<3; i++) posOut[i] = _base[i];
511 float span = _length * Math::cos(_sweep) * Math::cos(_dihedral);
512 span = 2*(span + Math::abs(_base[2]));
517 void Rotor::compile()
519 // Have we already been compiled?
520 if(_rotorparts.size() != 0) return;
522 //rotor is divided into 4 pointlike parts
524 SG_LOG(SG_FLIGHT, SG_DEBUG, "debug: e "
525 << _mincyclicele << "..." <<_maxcyclicele << ' '
526 << _mincyclicail << "..." << _maxcyclicail << ' '
527 << _min_pitch << "..." << _max_pitch);
531 _dynamic=_dynamic*(1/ //inverse of the time
532 ( (60/_rotor_rpm)/4 //for rotating 90 deg
533 +(60/_rotor_rpm)/(2*_number_of_blades) //+ meantime a rotorblade will pass a given point
535 float directions[5][3];//pointing forward, right, ... the 5th is ony for calculation
536 directions[0][0]=_forward[0];
537 directions[0][1]=_forward[1];
538 directions[0][2]=_forward[2];
540 SG_LOG(SG_FLIGHT, SG_DEBUG, "Rotor rotating ccw? " << _ccw);
545 Math::cross3(directions[i-1],_normal,directions[i]);
547 Math::cross3(_normal,directions[i-1],directions[i]);
548 Math::unit3(directions[i],directions[i]);
550 Math::set3(directions[4],directions[0]);
551 float rotorpartmass = _weight_per_blade*_number_of_blades/4*.453;//was pounds -> now kg
552 float speed=_rotor_rpm/60*_diameter*_rel_blade_center*pi;
553 float lentocenter=_diameter*_rel_blade_center*0.5;
554 float lentoforceattac=_diameter*_rel_len_hinge*0.5;
555 float zentforce=rotorpartmass*speed*speed/lentocenter;
556 _force_at_max_pitch=_force_at_pitch_a/_pitch_a*_max_pitch;
557 float maxpitchforce=_force_at_max_pitch/4*.453*9.81;//was pounds of force, now N
558 float torque0=0,torquemax=0;
559 float omega=_rotor_rpm/60*2*pi;
561 float omega0=omega*Math::sqrt(1/(1-_rel_len_hinge));
562 //float omega0=omega*Math::sqrt((1-_rel_len_hinge));
563 //_delta=omega*_delta;
564 _delta*=maxpitchforce/(_max_pitch*omega*lentocenter*2*rotorpartmass);
566 float phi=Math::atan2(2*omega*_delta,omega0*omega0-omega*omega);
567 //float relamp=omega*omega/(2*_delta*Math::sqrt(omega0*omega0-_delta*_delta));
568 float relamp=omega*omega/(2*_delta*Math::sqrt(Math::sqr(omega0*omega0-omega*omega)+4*_delta*_delta*omega*omega));
571 torque0=_power_at_pitch_0/4*1000/omega;
572 torquemax=_power_at_pitch_b/4*1000/omega/_pitch_b*_max_pitch;
582 SG_LOG(SG_FLIGHT, SG_DEBUG,
583 "spd: " << setprecision(8) << speed
584 << " lentoc: " << lentocenter
585 << " dia: " << _diameter
586 << " rbl: " << _rel_blade_center
587 << " hing: " << _rel_len_hinge
588 << " lfa: " << lentoforceattac);
589 SG_LOG(SG_FLIGHT, SG_DEBUG,
590 "zf: " << setprecision(8) << zentforce
591 << " mpf: " << maxpitchforce);
592 SG_LOG(SG_FLIGHT, SG_DEBUG,
593 "tq: " << setprecision(8) << torque0 << ".." << torquemax
594 << " d3: " << _delta3);
595 SG_LOG(SG_FLIGHT, SG_DEBUG,
596 "o/o0: " << setprecision(8) << omega/omega0
597 << " phi: " << phi*180/pi
598 << " relamp: " << relamp
599 << " delta: " <<_delta);
604 float lpos[3],lforceattac[3],lspeed[3],dirzentforce[3];
606 Math::mul3(lentocenter,directions[i],lpos);
607 Math::add3(lpos,_base,lpos);
608 Math::mul3(lentoforceattac,directions[i+1],lforceattac);//i+1: +90deg (gyro)!!!
609 Math::add3(lforceattac,_base,lforceattac);
610 Math::mul3(speed,directions[i+1],lspeed);
611 Math::mul3(1,directions[i+1],dirzentforce);
613 float maxcyclic=(i&1)?_maxcyclicele:_maxcyclicail;
614 float mincyclic=(i&1)?_mincyclicele:_mincyclicail;
617 Rotorpart* rp=rps[i]=newRotorpart(lpos, lforceattac, _normal,
618 lspeed,dirzentforce,zentforce,maxpitchforce, _max_pitch,_min_pitch,mincyclic,maxcyclic,
619 _delta3,rotorpartmass,_translift,_rel_len_hinge,lentocenter);
620 rp->setAlphaoutput(_alphaoutput[i&1?i:(_ccw?i^2:i)],0);
621 rp->setAlphaoutput(_alphaoutput[4+(i&1?i:(_ccw?i^2:i))],1+(i>1));
623 rp->setTorque(torquemax,torque0);
624 rp->setRelamp(relamp);
631 rps[i]->setlastnextrp(rps[(i+3)%4],rps[(i+1)%4],rps[(i+2)%4]);
636 float directions[5][3];//pointing forward, right, ... the 5th is ony for calculation
637 directions[0][0]=_forward[0];
638 directions[0][1]=_forward[1];
639 directions[0][2]=_forward[2];
641 SG_LOG(SG_FLIGHT, SG_DEBUG, "Rotor rotating ccw? " <<_ccw);
646 Math::cross3(directions[i-1],_normal,directions[i]);
648 // Math::cross3(_normal,directions[i-1],directions[i]);
649 Math::unit3(directions[i],directions[i]);
651 Math::set3(directions[4],directions[0]);
652 float speed=_rotor_rpm/60*_diameter*_rel_blade_center*pi;
653 float lentocenter=_diameter*_rel_blade_center*0.5;
654 float lentoforceattac=_diameter*_rel_len_hinge*0.5;
655 float zentforce=_weight_per_blade*.453*speed*speed/lentocenter;
656 _force_at_max_pitch=_force_at_pitch_a/_pitch_a*_max_pitch;
657 float maxpitchforce=_force_at_max_pitch/_number_of_blades*.453*9.81;//was pounds of force, now N
658 float torque0=0,torquemax=0;
659 float omega=_rotor_rpm/60*2*pi;
661 float omega0=omega*Math::sqrt(1/(1-_rel_len_hinge));
662 //float omega0=omega*Math::sqrt(1-_rel_len_hinge);
663 //_delta=omega*_delta;
664 _delta*=maxpitchforce/(_max_pitch*omega*lentocenter*2*_weight_per_blade*.453);
665 float phi=Math::atan2(2*omega*_delta,omega0*omega0-omega*omega);
666 float phi2=Math::abs(omega0-omega)<.000000001?pi/2:Math::atan(2*omega*_delta/(omega0*omega0-omega*omega));
667 float relamp=omega*omega/(2*_delta*Math::sqrt(Math::sqr(omega0*omega0-omega*omega)+4*_delta*_delta*omega*omega));
670 torque0=_power_at_pitch_0/_number_of_blades*1000/omega;
671 torquemax=_power_at_pitch_b/_number_of_blades*1000/omega/_pitch_b*_max_pitch;
681 SG_LOG(SG_FLIGHT, SG_DEBUG,
682 "spd: " << setprecision(8) << speed
683 << " lentoc: " << lentocenter
684 << " dia: " << _diameter
685 << " rbl: " << _rel_blade_center
686 << " hing: " << _rel_len_hinge
687 << " lfa: " << lentoforceattac);
688 SG_LOG(SG_FLIGHT, SG_DEBUG,
689 "zf: " << setprecision(8) << zentforce
690 << " mpf: " << maxpitchforce);
691 SG_LOG(SG_FLIGHT, SG_DEBUG,
692 "tq: " << setprecision(8) << torque0 << ".." << torquemax
693 << " d3: " << _delta3);
694 SG_LOG(SG_FLIGHT, SG_DEBUG,
695 "o/o0: " << setprecision(8) << omega/omega0
696 << " phi: " << phi*180/pi
697 << " relamp: " << relamp
698 << " delta: " <<_delta);
700 float lspeed[3],dirzentforce[3];
702 float f=(!_ccw)?1:-1;
703 //Math::mul3(f*speed,directions[1],lspeed);
704 Math::mul3(f,directions[1],dirzentforce);
705 for (i=0;i<_number_of_blades;i++)
711 Rotorblade* rb=newRotorblade(_base,_normal,directions[0],directions[1],
712 lentoforceattac,_rel_len_hinge,
713 dirzentforce,zentforce,maxpitchforce, _max_pitch,
714 _delta3,_weight_per_blade*.453,_translift,2*pi/_number_of_blades*i,
715 omega,lentocenter,/*f* */speed);
716 //rp->setAlphaoutput(_alphaoutput[i&1?i:(_ccw?i^2:i)],0);
717 //rp->setAlphaoutput(_alphaoutput[4+(i&1?i:(_ccw?i^2:i))],1+(i>1));
718 _rotorblades.add(rb);
719 rb->setTorque(torquemax,torque0);
720 rb->setDeltaPhi(pi/2.-phi);
721 rb->setDelta(_delta);
723 rb->calcFrontRight();
730 rps[i]->setlastnextrp(rps[(i-1)%4],rps[(i+1)%4],rps[(i+2)%4]);
738 Rotorblade* Rotor::newRotorblade(float* pos, float *normal, float *front, float *right,
739 float lforceattac,float rellenhinge,
740 float *dirzentforce, float zentforce,float maxpitchforce,float maxpitch,
741 float delta3,float mass,float translift,float phi,float omega,float len,float speed)
743 Rotorblade *r = new Rotorblade();
745 r->setNormal(normal);
748 r->setMaxPitchForce(maxpitchforce);
749 r->setZentipetalForce(zentforce);
750 r->setAlpha0(_alpha0);
751 r->setAlphamin(_alphamin);
752 r->setAlphamax(_alphamax);
753 r->setAlpha0factor(_alpha0factor);
758 r->setDirectionofZentipetalforce(dirzentforce);
759 r->setMaxpitch(maxpitch);
760 r->setDelta3(delta3);
761 r->setDynamic(_dynamic);
762 r->setTranslift(_translift);
764 r->setStepspersecond(_stepspersecond);
768 r->setLforceattac(lforceattac);
770 r->setLenHinge(rellenhinge);
771 r->setRelLenTeeterHinge(_rellenteeterhinge);
772 r->setTeeterdamp(_teeterdamp);
773 r->setMaxteeterdamp(_maxteeterdamp);
776 #define a(x) x[0],x[1],x[2]
777 printf("newrp: pos(%5.3f %5.3f %5.3f) pfa (%5.3f %5.3f %5.3f)\n"
778 " nor(%5.3f %5.3f %5.3f) spd (%5.3f %5.3f %5.3f)\n"
779 " dzf(%5.3f %5.3f %5.3f) zf (%5.3f) mpf (%5.3f)\n"
780 " pit (%5.3f..%5.3f) mcy (%5.3f..%5.3f) d3 (%5.3f)\n"
781 ,a(pos),a(posforceattac),a(normal),
782 a(speed),a(dirzentforce),zentforce,maxpitchforce,minpitch,maxpitch,mincyclic,maxcyclic,
789 Rotorpart* Rotor::newRotorpart(float* pos, float *posforceattac, float *normal,
790 float* speed,float *dirzentforce, float zentforce,float maxpitchforce,
791 float maxpitch, float minpitch, float mincyclic,float maxcyclic,
792 float delta3,float mass,float translift,float rellenhinge,float len)
794 Rotorpart *r = new Rotorpart();
796 r->setNormal(normal);
797 r->setMaxPitchForce(maxpitchforce);
798 r->setZentipetalForce(zentforce);
800 r->setPositionForceAttac(posforceattac);
803 r->setDirectionofZentipetalforce(dirzentforce);
804 r->setMaxpitch(maxpitch);
805 r->setMinpitch(minpitch);
806 r->setMaxcyclic(maxcyclic);
807 r->setMincyclic(mincyclic);
808 r->setDelta3(delta3);
809 r->setDynamic(_dynamic);
810 r->setTranslift(_translift);
813 r->setRelLenHinge(rellenhinge);
814 r->setOmegaN(_omegan);
815 r->setAlpha0(_alpha0);
816 r->setAlphamin(_alphamin);
817 r->setAlphamax(_alphamax);
818 r->setAlpha0factor(_alpha0factor);
822 SG_LOG(SG_FLIGHT, SG_DEBUG, setprecision(8)
824 << pos[0] << ' ' << pos[1] << ' ' << pos[2]
826 << posforceattac[0] << ' ' << posforceattac[1] << ' '
827 << posforceattac[2] << ')');
828 SG_LOG(SG_FLIGHT, SG_DEBUG, setprecision(8)
830 << normal[0] << ' ' << normal[1] << ' ' << normal[2]
832 << speed[0] << ' ' << speed[1] << ' ' << speed[2] << ')');
833 SG_LOG(SG_FLIGHT, SG_DEBUG, setprecision(8)
835 << dirzentforce[0] << ' ' << dirzentforce[1] << dirzentforce[2]
836 << ") zf (" << zentforce << ") mpf (" << maxpitchforce << ')');
837 SG_LOG(SG_FLIGHT, SG_DEBUG, setprecision(8)
838 << " pit(" << minpitch << ".." << maxpitch
839 << ") mcy (" << mincyclic << ".." << maxcyclic
840 << ") d3 (" << delta3 << ')');
844 void Rotor::interp(float* v1, float* v2, float frac, float* out)
846 out[0] = v1[0] + frac*(v2[0]-v1[0]);
847 out[1] = v1[1] + frac*(v2[1]-v1[1]);
848 out[2] = v1[2] + frac*(v2[2]-v1[2]);
851 }; // namespace yasim