#ifndef CRANK_ROCKING_BLOCK_MECHANISM_FORWARD_H #define CRANK_ROCKING_BLOCK_MECHANISM_FORWARD_H #include "FourBarMechanism/CrankSliderMechanism.h" #include #include #include #include // 曲柄摇块机构(正解) class CrankRockingBlockMechanism_Forward { private: std::string name; MechanismType type; MechanismParameters parameters; // 轨迹数据 std::vector trajectoryB; // 滑块B的轨迹 std::vector crankCirclePoints; // 曲柄端点A的轨迹 std::vector rockerTrajectory; // 摇块轨迹 // 性能统计 int frameCount; SimpleTimer timer; // 配置参数 double thetaADelta; double thetaAValueFactor; int thetaAFlip; public: CrankRockingBlockMechanism_Forward(); // 基本属性 std::string getName() const; MechanismType getType() const; MechanismParameters getParameters() const; void setParameters(const MechanismParameters ¶ms); // 设置连杆长度 void setLink(double OA, double AB, double OC); void setOA(double length); void setAB(double length); void setOC(double distance); // 配置方法 void setThetaADelta(double delta); void setThetaAValueFactor(double factor); void setThetaAFlip(int flip); // 主要计算函数 MechanismState calculate(double crankAngleDeg); // 获取输入范围 std::pair getInputRange(); // 轨迹相关 std::vector getTrajectoryPoints() const; std::vector getCrankCirclePoints() const; std::vector getRockerTrajectory() const; void clearTrajectory(); // 参数验证 ValidationResult validateParameters(); // 状态信息 std::string getStatusText(); // 获取配置参数 double getThetaADelta() const; double getThetaAValueFactor() const; int getThetaAFlip() const; double getOA() const; double getAB() const; double getOC() const; private: Vector2D calculatePointB(const Vector2D &A, const Vector2D &C, double AB); void checkLimitPositions(MechanismState &state, const Vector2D &A, const Vector2D &B, const Vector2D &C, double OA, double AB, double OC); double normalizeAngle(double angle); std::pair getValidCrankRange() const; bool checkFullRotationCondition(double OA, double AB, double OC) const; // 辅助方法 double degreesToRadians(double degrees) const; double radiansToDegrees(double radians) const; std::string formatDouble(double value, int precision = 3) const; }; #endif // CRANK_ROCKING_BLOCK_MECHANISM_FORWARD_H