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. 获取ip,获取客户端浏览器,获取客户端访问操作系统,获取客户端访问设备

    /** * 获取ip */ public static function getIp() { if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CL ...

  2. Golang接口简单了解

    在Golang中,一个类只需要实现了接口要求的所有函数,我们就说这个类实现了该接口. package main import "fmt" type Animal interface ...

  3. oracle闪回、闪回数据归档Flashback Data Archive (Oracle Total Recall)的真正强大之处、11gR2增强以及合理使用

    oracle的闪回很早就出来了,准确的说一直以来应该都较少被真正用户广为使用,除了dba和极少部分开发人员偶尔用于逻辑出错.误删恢复之外,较少被用于产生更有价值的用途. 各种闪回表flashback ...

  4. 解决在ubuntu中安装或升级时出现“11:资源暂时不可用”错误

    解决在ubuntu中安装或升级时出现“11:资源暂时不可用”错误 解决在ubuntu中安装或升级时出现“11:资源暂时不可用”错误. 下图为具体情况: 出现问题: termial下在执行sudo ap ...

  5. you must restart adb and eclipse的相关解决办法

    问题是5037端口被占用: C:\>netstat -aon|findstr "5037" 看到了吗,端口被进程号为5037的进程占用,继续执行下面命令(也可以去任务管理器中 ...

  6. FireMonkey 源码学习(2)

    三.TControl FireMonkey重写了TControl的代码,实现了众多接口,如下图: 基类上实现了众多功能,这里不详细描述. 四.TEdit 编辑框是从TControl—TStyledCo ...

  7. img的基线对齐问题

    http://blog.csdn.net/u011997156/article/details/44806523

  8. Android灯光系统_编写HAL_lights.c【转】

    本文转载自:https://blog.csdn.net/qq_33443989/article/details/77074411 1>. 编写灯光系统的HAL层 之 HAL_light.c1&l ...

  9. linux基础之vim编辑器

    vi : Visual Interface vim : VI Improved : VI的基础加上一些有用的插件 vim编辑器: 文本编辑器, 字处理器, 全屏编辑器, 模式化编辑器 vim的模式有三 ...

  10. docker版本升级

    docker的版本变化: Docker从1.13.x版本开始,版本分为企业版EE和社区版CE,版本号也改为按照时间线来发布,比如17.03就是2017年3月,有点类似于ubuntu的版本发布方式. 企 ...