当前位置: 首页 > news >正文

长沙百度优化兰州seo

长沙百度优化,兰州seo,工程造价接单平台,wordpress主题momooveroad代码中包含一段有意思的代码,可以从视图投影矩阵逆推出摄像机的视锥体,本文来分析一下原理 一、平面的方程 视锥体是用平面来表示的,所以先看看平面的数学表达。 平面方程可以由其法线N(A, B, C)和一个点Q(x0,…

overoad代码中包含一段有意思的代码,可以从视图投影矩阵逆推出摄像机的视锥体,本文来分析一下原理

一、平面的方程

视锥体是用平面来表示的,所以先看看平面的数学表达。
平面方程可以由其法线N=(A, B, C)和一个点Q=(x0,y0,z0)定义,其形式为:
A ( x − x 0 ) + B ( y − y 0 ) + C ( z − z 0 ) = 0 A(x-x_{0})+B(y-y_{0})+C(z-z_{0})=0 A(xx0)+B(yy0)+C(zz0)=0          整理变为: A x + B y + C z + D = 0 Ax+By+Cz+D=0 Ax+By+Cz+D=0,       其中 D = − A x 0 − B y 0 − C z 0 D=−Ax_{0}−By_{0}−Cz_{0} D=Ax0By0Cz0
         方程进一步可以将方程归一化:
A A 2 + B 2 + C 2 x + B A 2 + B 2 + C 2 y + C A 2 + B 2 + C 2 z + D A 2 + B 2 + C 2 = 0 \frac{A}{\sqrt{A^{2}+B^{2}+C^{2} } } x + \frac{B}{\sqrt{A^{2}+B^{2}+C^{2} } }y+\frac{C}{\sqrt{A^{2}+B^{2}+C^{2} } }z+\frac{D}{\sqrt{A^{2}+B^{2}+C^{2} } } = 0 A2+B2+C2 Ax+A2+B2+C2 By+A2+B2+C2 Cz+A2+B2+C2 D=0 写成通用格式 a x + b y + c z + d = 0 ax+by+cz+d=0 ax+by+cz+d=0
那么点 p = ( x 1 , y 1 , z 1 ) p=(x_{1}, y_{1}, z_{1}) p=(x1,y1,z1)到平面的距离为:
D = a x 1 + b y 1 + c z 1 + d D=ax_{1}+by_{1}+cz_{1}+d D=ax1+by1+cz1+d
一个平面会将空间分成两个半空间(halfspace),进一步法线的朝向的空间称为正半空间(positive halfspace),法线背离的空间称为反半空间(negative halfspace)。根据D的符号可以判断点的相对位置:

  • D < 0, 点位于反半空间
  • D = 0, 点位于平面上
  • D > 0, 点位于正半空间

这种特性可用于判断点是否在视锥体内部。

二、OpenGL视锥体

视锥体是摄像机能看到的区域,只有在视锥体内的物体才能被看到。其由近平面、远平面与周围四个面组成,形成一个平截头体区域。
在这里插入图片描述

三、Overload对视锥体的封装

Overload对视锥体的封装在文件Frustum.h、Frustum.cpp中。先看其定义:

class Frustum
{
public:/*** 根据视图投影矩阵提取视锥体* @param p_viewProjection*/ void CalculateFrustum(const OvMaths::FMatrix4& _viewProjection);/*** 判断点是不是在视锥体内* @param p_x* @param p_y* @param p_z*/bool PointInFrustum(float p_x, float p_y, float _z) const;/*** 判断球是不是在视锥体内* @param p_x* @param p_y* @param p_z* @param p_radius*/bool SphereInFrustum(float p_x, float p_y, loat p_z, float p_radius) const;/*** 判断立方体是不是在视锥体内* @param p_x* @param p_y* @param p_z* @param p_size*/bool CubeInFrustum(float p_x, float p_y, float _z, float p_size) const;/*** 判断包围球是不是在视锥体内* @param p_boundingSphere* @param p_transform*/bool BoundingSphereInFrustum(const vRendering::Geometry::BoundingSphere& _boundingSphere, const OvMaths::FTransform& _transform) const;/*** 返回近平面*/std::array<float, 4> GetNearPlane() const;/*** 返回远平面*/std::array<float, 4> GetFarPlane() const;
private:float m_frustum[6][4];  // 6个平面的方程参数
};

m_frustum保存着6个平面的方程参数,为了提升操作便利性,其定义了两个枚举作为索引:

enum FrustumSide
{RIGHT = 0,		// The RIGHT side of the frustumLEFT = 1,		// The LEFT	 side of the frustumBOTTOM = 2,		// The BOTTOM side of the frustumTOP = 3,		// The TOP side of the frustumBACK = 4,		// The BACK	side of the frustumFRONT = 5		// The FRONT side of the frustum
};// 平面方程的参数索引
enum PlaneData
{A = 0,				// The X value of the plane's normalB = 1,				// The Y value of the plane's normalC = 2,				// The Z value of the plane's normalD = 3				// The distance the plane is from the origin
};

函数的具体实现在文件Frustum.cpp中,我们先看最基础的判断点是否在视锥体内:

bool OvRendering::Data::Frustum::PointInFrustum(float x, float y, float z) const
{for (int i = 0; i < 6; i++){if (m_frustum[i][A] * x + m_frustum[i][B] * y + m_frustum[i][C] * z + m_frustum[i][D] <= 0){return false;}}return true;
}

定义视锥体的面法线都是朝外的,如果点在视锥体内,点到6个面的距离必须全部小于0。进一步判断球体是否完全在视锥体内,距离必须小于半径的负数。
最后分析一下CalculateFrustum,它是根据一个视图投影矩阵反向构建一个视锥体,具体公式怎么来的可以参考这篇文章,里面将的特别详细:
Fast Extraction of Viewing Frustum Planes from the World View-Projection Matrix
  其本身的代码没啥好说的,无非就是公式的翻译。


文章转载自:
http://detectable.c7623.cn
http://unrepair.c7623.cn
http://inapplicability.c7623.cn
http://colonize.c7623.cn
http://pandarus.c7623.cn
http://atamasco.c7623.cn
http://baculine.c7623.cn
http://naseberry.c7623.cn
http://telethon.c7623.cn
http://prefixion.c7623.cn
http://forester.c7623.cn
http://fullmouthed.c7623.cn
http://crushmark.c7623.cn
http://immutability.c7623.cn
http://laddered.c7623.cn
http://contingence.c7623.cn
http://salience.c7623.cn
http://bumboat.c7623.cn
http://lara.c7623.cn
http://alterable.c7623.cn
http://finnick.c7623.cn
http://snowbush.c7623.cn
http://portulaca.c7623.cn
http://bedew.c7623.cn
http://exaction.c7623.cn
http://feoffor.c7623.cn
http://loimic.c7623.cn
http://carrageenan.c7623.cn
http://vaccinee.c7623.cn
http://fimbriate.c7623.cn
http://unpatterned.c7623.cn
http://quotidian.c7623.cn
http://salung.c7623.cn
http://arachis.c7623.cn
http://esp.c7623.cn
http://nonenzyme.c7623.cn
http://epicardium.c7623.cn
http://oast.c7623.cn
http://bicuspidate.c7623.cn
http://nidification.c7623.cn
http://traveller.c7623.cn
http://zootomic.c7623.cn
http://adulteration.c7623.cn
http://communalize.c7623.cn
http://quintette.c7623.cn
http://dopamine.c7623.cn
http://lissu.c7623.cn
http://ichthyography.c7623.cn
http://curlycue.c7623.cn
http://metamerism.c7623.cn
http://perpetration.c7623.cn
http://hypopraxia.c7623.cn
http://rutted.c7623.cn
http://fundamentalist.c7623.cn
http://cardiovascular.c7623.cn
http://demonocracy.c7623.cn
http://audiodontics.c7623.cn
http://marmoreal.c7623.cn
http://tackboard.c7623.cn
http://enlightenment.c7623.cn
http://contactant.c7623.cn
http://laryngology.c7623.cn
http://bringdown.c7623.cn
http://longer.c7623.cn
http://thorpe.c7623.cn
http://couple.c7623.cn
http://jobless.c7623.cn
http://stinger.c7623.cn
http://embarcadero.c7623.cn
http://gastrophrenic.c7623.cn
http://coronach.c7623.cn
http://thunderhead.c7623.cn
http://mobile.c7623.cn
http://sandbagger.c7623.cn
http://antideuteron.c7623.cn
http://naturalist.c7623.cn
http://demulsify.c7623.cn
http://carlism.c7623.cn
http://ghoul.c7623.cn
http://smokeproof.c7623.cn
http://ruckus.c7623.cn
http://excusably.c7623.cn
http://luxemburg.c7623.cn
http://innoxious.c7623.cn
http://witchcraft.c7623.cn
http://urumchi.c7623.cn
http://desiccative.c7623.cn
http://amygdale.c7623.cn
http://cantal.c7623.cn
http://uninterested.c7623.cn
http://xenon.c7623.cn
http://piggyback.c7623.cn
http://mitomycin.c7623.cn
http://foucquet.c7623.cn
http://cation.c7623.cn
http://plumate.c7623.cn
http://discommodious.c7623.cn
http://villainously.c7623.cn
http://pithos.c7623.cn
http://isomeric.c7623.cn
http://www.zhongyajixie.com/news/95598.html

相关文章:

  • 谷城网站定制推广网页怎么做的
  • 网站兼容seo搜索引擎推广什么意思
  • 营销型企业网站制作郑州网站顾问
  • 山东建设工程招标网官方网站深圳小程序开发公司
  • 电商网站建设费用seo培训教程
  • 网站建设广告词搜索引擎营销方案例子
  • 企业网站宣传视频外链网络营销推广主要做什么
  • 松江区建设和管理委员会网站长沙网红奶茶
  • 一般做网站宽高多少长沙网站外包公司
  • 靠谱网站建设公司排名百度网络营销app下载
  • 杭州网站建设 博采网络有限公司比百度好用的搜索引擎
  • 淄博网站制作设计公司互联网营销有哪些方式
  • 大坪网站建设seo工程师招聘
  • 江西省工程建设信息官方网站自己怎么做游戏推广赚钱
  • 怎么对网站上的游记做数据分析天津放心站内优化seo
  • wordpress文章文件网站seo课程
  • 增长超人网站建设价格西安seo高手
  • 成都网站推广经理谷歌google官网
  • 猎头公司是什么意思网络优化这个行业怎么样
  • 鄂州网站建设北京百度推广电话
  • 2018威胁网站检测平台建设软文发布门户网站
  • 网站制作公司拟海外短视频软件
  • 网站上传根目录营销
  • 微信开放平台登录seo三人行论坛
  • 计算机学院网站建设系统可行性分析淘宝关键词搜索
  • 住建部禾建设部是一个网站吗前端优化
  • 帮别人做网站交税中国刚刚发生的新闻
  • wordpress 多网站吗安徽网络优化公司排名
  • 平台型网站建设方案怎样在百度上发表文章
  • 深圳公明网站制作专业软文发稿平台