简体   繁体   English

有人可以帮我解决几何变换问题吗?

[英]Can somebody please help me with a geometric transformation problem?

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. 我知道可以使用标准的canvas API来完成此操作,但我也需要处理椭圆弧的情况。 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 . 该代码背后的数学概念位于https://math.stackexchange.com/questions/53093/how-to-find-the-center-of-an-ellipse

My JS code is implementation of that. 我的JS代码就是该代码的实现。 My JS code can be found at http://jsfiddle.net/BkEnz/2/ . 我的JS代码可在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! 我过去几天一直在努力解决这个问题!

Fixed this issue. 解决了此问题。 The corrected working code is at http://jsfiddle.net/ZxRBT . 更正后的工作代码位于http://jsfiddle.net/ZxRBT

Notice the line 注意行

var t = translate(-R1R2x, -R1R2y, IDENTITY_TRANSFORM());

In my previous version of the code this line was 在我以前的代码版本中,这一行是

var t = translate(-R1R2x, -R1R2y, sr);

So when I was calculating the value of C1 and C2 , using the following code 因此,当我使用以下代码计算C1C2的值时

C1 = compose(vut, [[R1x],[R1y],[1]]);
C2 = compose(vut, [[R2x],[R2y],[1]]);

I was also applying the sr composition over R1x,R1y and R2x,R2y , but these points were already in sr coordinate. 我也将sr合成R1x,R1yR2x,R2y ,但是这些点已经在sr坐标中。

This was a grave mistake which I overlooked for really a long time. 这是一个严重的错误,我确实已经忽略了很长时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM