转载: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 表达式中,选取介于两个值 ...
随机推荐
- zabbix监控主机cpu达到80%后报警
在zabbix监控中,默认cpu监控模板中的触发器,当负载在一定时间内(比如最近5分钟)超过5以上为报警阀值.但是在实际场景中,由于服务器配置不一样,这个默认的cpu触发器用起来意义就不大了,这时候就 ...
- StackOverflow 问题
StackOverflow 这个问题一般是你的程序里头可能是有死循环或递归调用所产生的:可以查看一下你的程序,也可以增大你JVM的内存~~~在Eclipse中JDK的配置中加上 -XX:MaxD ...
- [linux] VirtualBox复制虚拟机
环境: Oracle VM VirtualBox 5.0.20 CentOS-6.7-x86_64-minimal.iso 1.复制虚拟机 -->右击休眠状态模板虚拟机,选择复制 -->填 ...
- 电梯调度系统(界面由C图形库编绘)
1.编程题目 电梯调度系统 2.结对编程组员 黄冠译,刘畅 3.编程语言 C语言图形库 4题目要求 编写人员:刘畅,黄冠译 代码如下: # include <stdio.h> # incl ...
- Being a (amateurish) team:团队开发体会
0x00 Being a (amateurish) team This is the process of changing hydrogen into breathable oxygen, and ...
- 【个人博客作业II】代码复审结果
[代码复审结果] General Does the code work? Does it perform its intended function, the logic is correct etc ...
- Linux内核分析——第四章 进程调度
第四章 进程调度 4.1 多任务 1.多任务操作系统就是能同时并发的交互执行多个进程的操作系统. 2.多任务操作系统使多个进程处于堵塞或者睡眠状态,实际不被投入执行,这些任务尽管位于内存,但是并不处于 ...
- Hibernate的初次使用
使用hibernate的四个步骤:第一:创建一个hibernate.cfg.xml.<!DOCTYPE hibernate-configuration PUBLIC "-//Hiber ...
- ThinkPad E470 win10,重装win10专业版后无声音
解决办法: 1.官网下载笔记本对应的声卡驱动并安装 2.下载热键驱动并安装 3.重启笔记本即可 参考:https://blog.csdn.net/u012369373/article/details/ ...
- HMM模型学习笔记(维特比算法)
维特比算法(Viterbi) 维特比算法 编辑 维特比算法是一种动态规划算法用于寻找最有可能产生观测事件序列的-维特比路径-隐含状态序列,特别是在马尔可夫信息源上下文和隐马尔可夫模型中.术语“维特比 ...