tailieunhanh - 3D Graphics with OpenGL ES and M3G- P33
3D Graphics with OpenGL ES and M3G- P33:Mobile phones are the new vehicle for bringing interactive graphics technologies to consumers. Graphics that in the 1980s was only seen in industrial flight simulators and at the turn of the millennium in desktop PCs and game consoles is now in the hands of billions of people. This book is about the technology underpinnings of mobile threedimensional graphics, the newest and most rapidly advancing area of computer graphics. | 304 BASIC M3G CONCEPTS CHAPTER 13 pre or to the right post of the current R scaling and translation are order-independent. These methods take the same parameters as their setter counterparts. Transformable also defines a getter for each of the four components as well as for the composite transformation C void getTranslation float translation void getOrientation float angleAxis void getScale float scale void getTransform Transform transform void getCompositeTransform Transform transform Note that there is indeed only one getter for each component not separate ones for tx ty tz angle and so on. Consistent with the API conventions the values are filled in to a float array or Transform object designated by the user thus facilitating object reuse. Rotations Rotations in Transformable are specified in the axis-angle format which is very intuitive but unfortunately less robust and sometimes less convenient than quaternions. There are no utility methods in the API to convert between the two representations but luckily this is quite simple to do in your own code. Denoting a normalized axis-angle pair by a 0 ax ay az 0 and a unit quaternion by q qv qw qx qy qz qw the conversions are as follows qv qw asin 0 2 cos 0 2 qv 1 a 0 - q . 1 2 acos qw Both formulas assume the input axis or quaternion to be normalized and will produce normalized output. If the axis-angle output is intended for M3G however you do not need to normalize the axis because M3G will do that in any case. You may therefore skip the square root term yielding a significantly faster conversion from quaternion to axis-angle a 0 qv 2acos qw . In other words only the rotation angle needs to be computed because qv can be used as the rotation axis as such. Remember that the angle needs to be degrees and if your acos returns the angle in radians the resulting 0 must be multiplied with 180 . Note that the input quaternion must still be normalized or else acos qw will yield an incorrect value for 0. A .
đang nạp các trang xem trước