有人可以帮我解决几何变换问题吗?
我需要在两个给定点之间绘制圆弧。我还有圆弧的半径。我知道这可以使用标准 canvas
API 来完成,但我也需要处理椭圆弧的情况。这段代码是一个通用的解决方案。现在唯一的问题是它不起作用!
此代码背后的数学概念位于 https://math。 stackexchange.com/questions/53093/how-to-find-the-the-center-of-an-ellipse。
我的 JS 代码就是它的实现。我的 JS 代码可以在 http://jsfiddle.net/BkEnz/2/ 找到。理想情况下,两个圆圈都应该穿过两个粉红色的小点。
我希望有人能指出我正确的方向。过去几天我一直在努力解决这个问题!
I need to draw a circular arc between two given points. I also have the arc's radius. I understand that this can be done using standard canvas
APIs but I need to handle the case of elliptical arcs too. This code is a generalized solution. The only problem right now is that it doesn't work!
The mathematical concept behind this code is at https://math.stackexchange.com/questions/53093/how-to-find-the-center-of-an-ellipse.
My JS code is implementation of that. My JS code can be found at http://jsfiddle.net/BkEnz/2/. Ideally both the circles there should pass through the two little pink dots.
I hope somebody can point me towards the right direction. I have been trying to solve this for past few days now!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复了这个问题。更正后的工作代码位于 http://jsfiddle.net/ZxRBT。
请注意,
在我之前版本的代码中,这一行是
因此,当我计算
C1
和C2
的值时,使用以下代码我还应用了
sr
合成在R1x,R1y
和R2x,R2y
上,但这些点已经在sr
坐标中。这是一个严重的错误,我很长一段时间都忽略了它。
Fixed this issue. The corrected working code is at http://jsfiddle.net/ZxRBT.
Notice the line
In my previous version of the code this line was
So when I was calculating the value of
C1
andC2
, using the following codeI was also applying the
sr
composition overR1x,R1y
andR2x,R2y
, but these points were already insr
coordinate.This was a grave mistake which I overlooked for really a long time.