//近似计算两坐标间的直线距离 // 为使得计算结果准确,需保证本函数两个入参坐标的连线,要么与坐标轴平行,要么与坐标轴呈45度角 // 原因:本游戏的角色移动,只有八个方向,每两个临近方向的夹角是45度角; // 任何角色的移动路径,必须保证其中的坐标点均是拐点;以方便服务端做近视计算 // //@param pos1 坐标1 //@param pos2 坐标2 //@param direct 返回的方向 //@return >=0 两坐标的直线距离 <0 失败 double Creature::CalcPosDistance( ArchvPosition &pos1, ArchvPosition &pos2, Byte & direct ) { UInt32 absX = abs(pos1.X-pos2.X); UInt32 absY = abs(pos1.Y-pos2.Y); //计算方向 direct = CalcDirect( pos1, pos2 ); //计算两点间距离 if( absX > 0 && absY > 0 ) return 1.41421 * absX; return (absX+absY); }
// Set actual values of wheels (steer/drive velocity/position) (Istwerte) void UndercarriageCtrlGeom::SetActualWheelValues(std::vector<double> vdVelGearDriveRadS, std::vector<double> vdVelGearSteerRadS, std::vector<double> vdDltAngGearDriveRad, std::vector<double> vdAngGearSteerRad) { //LOG_OUT("Set Wheel Position to Controller"); m_vdVelGearDriveRadS = vdVelGearDriveRadS; m_vdVelGearSteerRadS = vdVelGearSteerRadS; m_vdDltAngGearDriveRad = vdDltAngGearDriveRad; m_vdAngGearSteerRad = vdAngGearSteerRad; // calc exact Wheel Positions (taking into account lever arm) CalcExWheelPos(); // Peform calculation of direct kinematics (approx.) based on corrected Wheel Positions CalcDirect(); }