转载:OSG::Quat(四元数)用法
转自:http://blog.163.com/dj_zone/blog/static/4908931320098294047820/
osg::Quat
To set the attitude of a node or group of nodes, we use a new object, the osg::Quat. An osg::Quat is used to instantiate a quaternion, which we use to rotate objects. The two functions that we will use to apply rotation transformations to a PAT node are:
|
void setAttitude(const Quat& quat); |
We simply construct a new osg::Quat whenever we want to rotate a PAT. The two declarations for an osg::Quat are:
|
osg::Quat(value_type angle, const Vec3d &axis) |
The first constructor creates a osg::Quat with a facing of angle in radians around one or more axes defined within the osg::Vec3d. For example:
|
osg::Quat(1.2, osg::Vec3d(1.0, 0.0, 1.0)); |
This will create a quaternion that has the properties of rotating 1.2 radians around the x and z axis. For the axis, a value of 1.0 will represent a rotation around that axis, with a value of 0.0 producing no rotation. Also note that because there is but a single angle of rotation, all the axes will be rotated by the same amount if they are flagged for rotation. That is, with this constructor, I cannot rotate 3.0 radians around the x axis and 4.0 radians around the y axis. That requires a more complicated system where there is an individual angle for each axis. For example:
|
osg::Quat( |
This constructor is used when the angle of rotation around more than one axis should not be equal. In the above example, we rotate 1.0 radians around the x axis, 2.0 around the y, and 0.0 around the z.
I find it easier to use degrees rather than radians, and OSG helps with degree usage by offering the following function to convert degrees into radians:
|
osg::DegreesToRadians(<some_degree_value>); |
The osg::DegreesToRadians function returns a double. Note that, like translations, rotation angles are offsets from initial values, so unless we keep increasing or changing the rotational angle, the object will not rotate. Setting the attitude of a PAT with the Quat of (5.0, (1.0, 0.0, 0.0)) will NOT rotate the object 5 units per iteration around the x axis. Instead it will rotate the object 5 radians around the x axis on first call, and it will stay that way until the angle is changed.
转载:OSG::Quat(四元数)用法的更多相关文章
- 【转载】ssh-keygen 基本用法
[转载]ssh-keygen 基本用法 原文地址:https://www.liaohuqiu.net/cn/posts/ssh-keygen-abc/ ssh 公钥认证是ssh认证的方式之一.通过公钥 ...
- 【转载】 mysql explain用法
转载链接: mysql explain用法 官网说明: http://dev.mysql.com/doc/refman/5.7/en/explain-output.html 参数: htt ...
- [转载] extern "C"的用法解析
本文转载自: http://www.cnblogs.com/rollenholt/archive/2012/03/20/2409046.html 1.引言 C++语言的创建初衷是“a better ...
- (转载)C# 枚举 FlagsAttribute用法
这是读过几篇文章后发现整理的最完整的一篇文章 转载地址:枚举特性FlagsAttribute的用法 先看官方的解释:指示可以将枚举作为位域(即一组标志)处理. 看起来并不好理解,到底什么是作为位域处理 ...
- 【转载】Java DecimalFormat 用法
转载只供个人学习参考,以下查看请前往原出处:http://blog.csdn.net/wangchangshuai0010/article/details/8577982 我们经常要将数字进行格式化, ...
- 转载:python argparse用法总结
https://www.jianshu.com/p/fef2d215b91d 1. argparse介绍 是python的一个命令行解析包,非常编写可读性非常好的程序 2. 基本用法 prog.py是 ...
- 【转载】CreateProcess的用法
第一.第二个参数的用法: 例子: 使用ie打开指定的网页. 注意第二个参数是 可执行文件+命令行参数 #include "stdafx.h" #include <window ...
- (转载)delphi checklistbox用法
delphi checklistbox用法 在Delphi中checklistbox中高亮选中(不论是否Checked)能够进行操作么?删除,上下移动等等 删除:CheckListBox.Delete ...
- (转载)MySQL BETWEEN 用法
(转载)http://www.5idev.com/p-php_mysql_between.shtml MySQL BETWEEN 语法 BETWEEN 运算符用于 WHERE 表达式中,选取介于两个值 ...
随机推荐
- REST-framework快速构建API--源码解析
一.APIView 通过APIView实现API的过程如下: urls.py url(r'^books/$', views.BookView.as_view(),name="books&qu ...
- myeclipse、maven、tomcat、jdk技巧和坑【待完善】
公司使用前后不分离或半分离的springmvc + maven ,自己不得不研究研究myeclipse.maven.tomcat等等 开发环境搭建:坑一: Unable to process Jar ...
- QQ群管理员申请帖(本次截止日期为2017-03-25)
本帖专门为技术交流群申请管理员专用. 管理员的权利: 1.有权在成员违规的情况下直接剔除. 2.有权加入多个交流群. 3.有权引人入群. 4.艾特全体是权利,但要慎用,通常情况下,没有我本人的授意,不 ...
- Linux下rsyslog日志收集服务环境部署记录
rsyslog 可以理解为多线程增强版的syslog. 在syslog的基础上扩展了很多其他功能,如数据库支持(MySQL.PostgreSQL.Oracle等).日志内容筛选.定义日志格式模板等.目 ...
- 2016.3.24 OneZero站立会议
会议时间:2016.3.24 15:35-15:55 会议成员:王巍 夏一名 冉华 张敏 会议内容: 1.确立UI界面原形(见http://www.cnblogs.com/zhangminss/p/5 ...
- Linux内核分析 笔记六 进程的描述和进程的创建 ——by王玥
一.知识点总结 (一)进程的描述 1.操作系统内核里有三大功能: 进程管理 内存管理 文件系统 2.进程描述符:task_struct 2.进程描述符——struct task_struct 1. p ...
- 原生js作用域(红宝书)
function fn(){ ; alert(a); // 2; } alert(a);//未被定义: alert(b);//全局变量:b=2: ; function fn1(){ ; functio ...
- poj 3177 Redundant Paths(边双连通分量+缩点)
链接:http://poj.org/problem?id=3177 题意:有n个牧场,Bessie 要从一个牧场到另一个牧场,要求至少要有2条独立的路可以走.现已有m条路,求至少要新建多少条路,使得任 ...
- hive启动方式
- CSS实现水平居中的5种思路
前面的话 水平居中是经常遇到的问题.看似方法较多,条条大路通罗马.但系统梳理下,其实都围绕着几个思路展开.本文将介绍关于水平居中的5种思路 text-align [思路一]:在父元素中设置text-a ...