简体   繁体   English

绕轴旋转椭圆

[英]rotating an ellipse about an axis

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)并且我不断添加角度angle = angle + taninverse(ry / rx)

the angle is too small to see the difference. 角度太小,看不到差异。 please provide another formula to calctulate teh angle with the given 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

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. 好处是您可以简单地将此delta变量设置为所需的任何值,无论大小。 As above, you can increment angle by this delta value. 如上所述,您可以按此delta值增加angle

There are some animation classes in Android. Android中有一些动画类。 The package android.animation is available since API 11 and provides the ability animate object properties. 自API 11起,即可使用android.animation软件包,该软件包可对对象属性进行动画处理。 android.view.animation is available from API 1 and provides animations for resizing, moving, and rotating. android.view.animation可从API 1获得,并提供用于调整大小,移动和旋转的动画。 Both also offer XML attributes so you can also set you animation in XML. 两者都提供XML属性,因此您还可以设置XML动画。 The main classes to check out are android.view.animation.Animation and android.animation.Animator. 要检出的主要类是android.view.animation.Animation和android.animation.Animator。

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

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