1.cos趋近

// a reasonable approximation of cosine interpolation
double
smoothStepInterp( double t ) {
return (t*t)*(3.0-2.0*t);
}

2.pow趋近

// rough approximation of pow(x,y)
double
powFast( double x, double y ) {
return x/(x+y-y*x);
}

3.

// accel/decel curve (a < 0 => decel)
double
accelerationInterp( double t, double a ) {
return a == 0.0? t : a > 0.0? powFast( t, a ) : 1.0 - powFast(1.0-t, -a);
}

4.

// normalized linear intep
osg::Vec3d nlerp(const osg::Vec3d& a, const osg::Vec3d& b, double t) {
double am = a.length(), bm = b.length();
osg::Vec3d c = a*(1.0-t) + b*t;
c.normalize();
c *= (1.0-t)*am + t*bm;
return c;
}

5.

// linear interp
osg::Vec3d lerp(const osg::Vec3d& a, const osg::Vec3d& b, double t) {
return a*(1.0-t) + b*t;
}

6.

osg::Matrix computeLocalToWorld(osg::Node* node) {
osg::Matrix m;
if ( node ) {
osg::NodePathList nodePaths = node->getParentalNodePaths();
if ( nodePaths.size() > ) {
m = osg::computeLocalToWorld( nodePaths[] );
}
else {
osg::Transform* t = dynamic_cast<osg::Transform*>(node);
if ( t ) {
t->computeLocalToWorldMatrix( m, 0L );
}
}
}
return m;
}

7.

osg::Vec3d computeWorld(osg::Node* node) {
return node ? osg::Vec3d(,,) * computeLocalToWorld(node) : osg::Vec3d(,,);
}

8.

double normalizeAzimRad( double input )
{
if(fabs(input) > *osg::PI)
input = fmod(input,*osg::PI);
if( input < -osg::PI ) input += osg::PI*2.0;
if( input > osg::PI ) input -= osg::PI*2.0;
return input;
}

[原][c++][数学]osg常用图形数学算法小结的更多相关文章

  1. Delphi 常用函数(数学函数)round、trunc、ceil和floor

    源:Delphi 常用函数(数学函数)round.trunc.ceil和floor Delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里 ...

  2. 【python游戏编程之旅】第四篇---pygame中加载位图与常用的数学函数。

    本系列博客介绍以python+pygame库进行小游戏的开发.有写的不对之处还望各位海涵. 在上一篇博客中,我们学习了pygame事件与设备轮询.http://www.cnblogs.com/msxh ...

  3. (转载)delphi 常用函数(数学)

    delphi 常用函数(数学) Delphi中怎么将实数取整? floor 和 ceil 是 math unit 里的函数,使用前要先 Uses Math.trunc 和 round 是 system ...

  4. 开源Math.NET基础数学类库使用(07)一些常用的数学物理常数

    原文:[原创]开源Math.NET基础数学类库使用(07)一些常用的数学物理常数               本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/ ...

  5. 【python游戏编程04--加载位图与常用的数学函数】

    一.pygame中常用的数学函数 首先介绍两个角度和弧度转换的函数 math.degress()和math.radians()用法很简单,只要将数值传进去然后接受返回值就可以 math.cos(ang ...

  6. iOS开发中常用的数学函数

    iOS开发中常用的数学函数 /*---- 常用数学公式 ----*/ //指数运算 3^2 3^3 NSLog(,)); //result 9 NSLog(,)); //result 27 //开平方 ...

  7. php常用函数——数学函数

    php常用函数——数学函数

  8. python numpy常用的数学和统计函数

    numpy模块的核心就是基于数组的运算,相比于列表和其他数据结构,数组的运算效率是最高的.在统计分析和挖掘过程中,经常会使用到numpy模块的函数,以下是常用的数学函数和统计函数: 常数p就是圆周率  ...

  9. 每天进步一点点------Alpha半透明图形叠加算法Matlab+Verilog实现

    Alpha图形叠加算法Matlab+Verilog实现 1.1. Alpha算法的研究 Alpha通道是一个8位的灰度通道,该通道用256级灰度来记录图像中的透明度信息,定义透明.不透明和半透明区域, ...

随机推荐

  1. php开启xdebug扩展

    1.下载Xdebug(先看php下的ext文件夹(C:\xampp\php\ext)下有没有php_xdebug.dll文件,如果有的话,就不用下了.) 到目前为止,Xdebug的最新版本为2.7.0 ...

  2. Selenium+Headless Firefox

    背景 今天本地调试基于Selenium+PhantomJS的动态爬虫程序顺利结束后,着手部署到服务器上,刚买的热乎的京东云,噼里啪啦一顿安装环境,最后跑的时候报了这么个错误: UserWarning: ...

  3. FAT16/32不等于ESP:windows安装程序无法将windows配置为在此计算机的硬件上运行

    今天给公司电脑装系统,由于公司特殊需要,要给新电脑装win7系统.三台完全一样的华硕adol笔记本,前两台都和win10并存装成了双系统,第三台被不懂系统的人尝试装win7搞坏了,只能全盘格式化后再装 ...

  4. 在见证了1000多家公司的兴衰灭亡之后,YC创始合伙人总结了创业公司的6个不死法则(转)

    今天,我想先说一下个人消息.在 YC 工作了 11 年之后,我明年想去休假.我希望把精力放在一些项目上,说实话,我有点累了. YC 是这世界上我最喜欢的事情之一,但它也很费精力. 11 年不间断的耗费 ...

  5. mysql "The user specified as a definer ('root'@'%') does not exist" 问题

    在重配mysql的时候碰到, 解决办法: 重新授权 grant all privileges on *.* to root@"%" identified by ".&qu ...

  6. bash 配置文件

    两类: profile类:为交互式登录的shell进程提供配置 bashrc类:为非交互式登录的shell进程提供配置 登录类型: 交互式登录shell进程: 直接通过某终端输入账号和密码后登录打开的 ...

  7. django基础 -- 7.Ajax

    一.ajax 的特点 1.异步交互:客户端发出一个请求后,需要等待服务器响应结束后, 才能发出第二个请求 2.局部刷新:给用户的感受是在不知不觉中完成请求和响应过程. 二.ajax 模板示例 ($.a ...

  8. Git和Jenkins日记之没有新提交代码

    日期:2017/3/9 今天查看Jenkins运行代码记录的日志时,发现并没有昨天新提交的代码,然后查看了Jenkins的测试项目中所有的自动化测试用例, 并没有看到昨天新提交的测试用例,又查看了gi ...

  9. 启动Activiti项目报错:org.activiti.engine.ActivitiObjectNotFoundException: no deployed process definition found with id '22501'

    背景 启动activiti项目时,出现错误org.activiti.engine.ActivitiObjectNotFoundException: no deployed process defini ...

  10. 探究is与==的区别

    1.is  和 ==的区别: 主要参考内存地址: 部分字符串和数字有固定的小数据池: 比如: a="abc" a1="abc" print(id(a),id(a ...