if i make an ellipse bounded by a rectangle. how can i rotate it ? as in if i have rx,ry,cx,cy,topleft x,toplefy, bottomrightx,bottomrighty
如果我做一个由矩形限定的椭圆。我怎么旋转它?如果我有rx,ry,cx,cy,topleft x,toplefy,bottomrightx,bottomrighty
iused the formula
我使用了这个公式
angle=taninverse(ry/rx) and i keep adding the angle that is angle=angle + taninverse(ry/rx)
angle = taninverse(ry / rx)并且我继续添加角度=角度=角度+ taninverse(ry / rx)
the angle is too small to see the difference. please provide another formula to calctulate teh angle with the given parmeteres
角度太小,看不出差异。请提供另一个公式,用给定的parmeteres来调整角度
to have a look at the ellipse with the bounded rectangle frame http://svg-edit.googlecode.com/svn/branches/2.5.1/editor/svg-editor.html
用有界矩形框架查看椭圆http://svg-edit.googlecode.com/svn/branches/2.5.1/editor/svg-editor.html
2 个解决方案
#1
1
Have you tried rotating by a larger angle to see what happens? Do the values of rx and ry change?
您是否尝试过更大的角度旋转以查看会发生什么? rx和ry的值是否会改变?
If not, you probably should compute 'atan(ry/rx)' and store the result in a variable like so:
如果没有,你可能应该计算'atan(ry / rx)'并将结果存储在一个变量中:
double delta = Math.atan(ry / rx);
Then when you rotate
然后当你旋转
angle += delta; // or angle = angle + delta --- these are equivalent
Alternatively, rather than calculating the angle from ry and rx, you may wish to simply keep a value such as
或者,您可能希望简单地保留一个值,例如,而不是从ry和rx计算角度
double delta = Math.PI / 6;
This simply gives the angle to rotate through without a calculation. The advantage is that you can simply set this delta
variable to any value you wish, large or small. As above, you can increment angle
by this delta
value.
这简单地给出了在没有计算的情况下旋转的角度。优点是您可以简单地将此delta变量设置为您希望的任何值,无论大小。如上所述,您可以通过此增量值增加角度。
#2
-1
There are some animation classes in Android. The package android.animation is available since API 11 and provides the ability animate object properties. android.view.animation is available from API 1 and provides animations for resizing, moving, and rotating. Both also offer XML attributes so you can also set you animation in XML. The main classes to check out are android.view.animation.Animation and android.animation.Animator.
Android中有一些动画类。 android.animation包自API 11开始提供,并提供动画对象属性的功能。 android.view.animation可从API 1获得,并提供用于调整大小,移动和旋转的动画。两者都提供XML属性,因此您还可以使用XML设置动画。要检查的主要类是android.view.animation.Animation和android.animation.Animator。
#1
1
Have you tried rotating by a larger angle to see what happens? Do the values of rx and ry change?
您是否尝试过更大的角度旋转以查看会发生什么? rx和ry的值是否会改变?
If not, you probably should compute 'atan(ry/rx)' and store the result in a variable like so:
如果没有,你可能应该计算'atan(ry / rx)'并将结果存储在一个变量中:
double delta = Math.atan(ry / rx);
Then when you rotate
然后当你旋转
angle += delta; // or angle = angle + delta --- these are equivalent
Alternatively, rather than calculating the angle from ry and rx, you may wish to simply keep a value such as
或者,您可能希望简单地保留一个值,例如,而不是从ry和rx计算角度
double delta = Math.PI / 6;
This simply gives the angle to rotate through without a calculation. The advantage is that you can simply set this delta
variable to any value you wish, large or small. As above, you can increment angle
by this delta
value.
这简单地给出了在没有计算的情况下旋转的角度。优点是您可以简单地将此delta变量设置为您希望的任何值,无论大小。如上所述,您可以通过此增量值增加角度。
#2
-1
There are some animation classes in Android. The package android.animation is available since API 11 and provides the ability animate object properties. android.view.animation is available from API 1 and provides animations for resizing, moving, and rotating. Both also offer XML attributes so you can also set you animation in XML. The main classes to check out are android.view.animation.Animation and android.animation.Animator.
Android中有一些动画类。 android.animation包自API 11开始提供,并提供动画对象属性的功能。 android.view.animation可从API 1获得,并提供用于调整大小,移动和旋转的动画。两者都提供XML属性,因此您还可以使用XML设置动画。要检查的主要类是android.view.animation.Animation和android.animation.Animator。