求旋转椭圆的角度
Find the angle of a rotated ellipse
本文关键字:旋转 更新时间:2023-10-16
我正在使用dxflib库开发DXF解析器。我在解析省略号时遇到问题。
当我解析椭圆时,我会收到以下数据:
struct DL_EllipseData
{
/*! X Coordinate of center point. */
double cx;
/*! Y Coordinate of center point. */
double cy;
/*! X coordinate of the endpoint of the major axis. */
double mx;
/*! Y coordinate of the endpoint of the major axis. */
double my;
/*! Ratio of minor axis to major axis. */
double ratio;
};
我正试图用下面的方程式来计算这个角度:
auto angle = std::atan2(ellipse.my, ellipse.mx);
但它给了我错误的结果(例如,如果角度是16度,它会给我大约74度)。
我应该如何正确计算旋转角度?
您忽略了椭圆的平移,也就是说,中心可能不位于(0,0)。如果是这种情况,你的解决方案是可以的。
要消除平移的影响,只需减去中心的坐标:
auto angle = std::atan2(ellipse.my - ellipse.cy, ellipse.mx - ellipse.cx);
相关文章:
- 与互斥锁相比,旋转锁可以保证上下文切换
- 绘制旋转的三角形
- 旋转模型矩阵时的形状失真
- 四边形的 2D 旋转
- 垂直方向的 Gtk3+ 旋转按钮 (c/c++)
- 发布旋转矩阵(openGL/glm)
- 顺时针迭代旋转 3 位数字
- 形状对象的旋转和缩放不正确C++
- 如何在 OpenSceneGraph 中缩放/旋转/移动资产
- 如何有效地计算将单位立方体映射到自身的反射和旋转?
- 子轴围绕父轴而不是他自己的轴旋转
- 将使用太多的纹理插值器 - 带旋转的着色器
- SFML 向下移动时如何围绕屏幕中心旋转?
- 如何在OpenGL中正确旋转和缩放对象?
- 使用 C++在 OpenGL 中移动自动旋转的 3D 多边形
- 按时间自动旋转形状,同时在 OpenGL 中使用C++移动它们
- 如何使用增强::几何计算多边形的旋转固体体积?
- 使用 GDI+ 旋转位图,然后转换为 HDC
- 如何绕任意轴旋转点?
- 程序仅正确旋转方形图像