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

网站营销型企业销售平台如何在网站上做咨询浮动窗口

网站营销型企业销售平台,如何在网站上做咨询浮动窗口,wordpress去除版权,wordpress空间安装教程视频题目 光线追踪的核心算法: 1.光线的生成 2.光线与三角的相交 题解 1.光线的生成 如课件中的图所示#xff1a; image plane 就是 代码中的scene的FrameBuffer。 但是#xff0c;FrameBuffer 是窗口坐标系中#xff0c;而光线是世界坐标系中的。所以我们需要将scene中的屏…题目 光线追踪的核心算法: 1.光线的生成 2.光线与三角的相交 题解 1.光线的生成 如课件中的图所示 image plane 就是 代码中的scene的FrameBuffer。 但是FrameBuffer 是窗口坐标系中而光线是世界坐标系中的。所以我们需要将scene中的屏幕坐标 p o s s c r e e n pos_{screen} posscreen​转换为世界坐标 p o s w o r l d pos_{world} posworld​, 这个就可以按照作业3 坐标转换回顾 中局部坐标到窗口坐标的变换进行逆变换就可以了。 为了简化操作观察点在原点image plane 在 ( 0 , 0 , − 1 ) (0,0,-1) (0,0,−1)位置如此世界变换矩阵、观察矩阵都是单位矩阵。接下来只需要做投影变换、透视除法和视口变换的逆变换即可。由于z值已知所以在推算的过程中可以不考虑z值。通过手动推算可以得到以下公式 x w o r l d a s p e c t ∗ t a n ( f o v 2 ) ∗ ( 1 − 2 w ∗ x s c r e e n ) y w o r l d t a n ( f o v 2 ) ∗ ( 1 − 2 w ∗ y s c r e e n ) x_{world}aspect * tan(\frac{fov}{2})* (1 - \frac{2}{w} * x_{screen} ) \\ y_{world}tan(\frac{fov}{2})* ( 1 - \frac{2}{w} * y_{screen} ) xworld​aspect∗tan(2fov​)∗(1−w2​∗xscreen​)yworld​tan(2fov​)∗(1−w2​∗yscreen​) x w o r l d x_{world} xworld​ 为世界坐标 x s c r e e n x_{screen} xscreen​ 为屏幕坐标注意最后需要根据左右手和 窗口坐标系和屏幕坐标系的y轴反向加上相应的正负号。 最终image plane 中的 每个像素的世界坐标减去观察点eye_pos(0,0,0) 然后归一化即可得到光线的方向。 具体的代码如下 std::vectorVector3f framebuffer(scene.width * scene.height);float scale std::tan(deg2rad(scene.fov * 0.5f));float imageAspectRatio scene.width / (float)scene.height;// Use this variable as the eye position to start your rays.Vector3f eye_pos(0);int m 0;for (int j 0; j scene.height; j){for (int i 0; i scene.width; i){// generate primary ray directionfloat x0;float y0;// TODO: Find the x and y positions of the current pixel to get the direction// vector that passes through it.// Also, dont forget to multiply both of them with the variable *scale*, and// x (horizontal) variable with the *imageAspectRatio* // 将屏幕坐标转换为NDC坐标// 然后将NDC坐标转换为世界坐标x (2 * (i 0.5) / (float)scene.width - 1) * scale * imageAspectRatio;y (1 - 2 * (j 0.5) / (float)scene.height) * scale;Vector3f dir Vector3f(x, y, -1); // Dont forget to normalize this direction!dir normalize(dir);framebuffer[m] castRay(eye_pos, dir, scene, 0);}UpdateProgress(j / (float)scene.height);}光线和三角形相交 课程中介绍了两种方式第一种比较好理解就是先判断射线是否和平面相交如果相交在判断交点是否在三角形内部。 如ppt 中所示 第二种方式Moller Trubmber 算法这种方式可以一次计算出 t以及交点在重心坐标系中的坐标值。Moller Trubmber 算法的推导可以参考文档 根据公式实现的代码如下 bool rayTriangleIntersect(const Vector3f v0, const Vector3f v1, const Vector3f v2, const Vector3f orig,const Vector3f dir, float tnear, float u, float v) {// TODO: Implement this function that tests whether the triangle// thats specified bt v0, v1 and v2 intersects with the ray (whose// origin is *orig* and direction is *dir*)// Also dont forget to update tnear, u and v.// reference: moller trubmbore algorithmVector3f v0v1 v1 - v0;Vector3f v0v2 v2 - v0;Vector3f pvec crossProduct(dir, v0v2);float det dotProduct(v0v1, pvec);if (fabs(det) 1e-8) return false;float invDet 1 / det;Vector3f tvec orig - v0;u dotProduct(tvec, pvec) * invDet;if (u 0 || u 1) return false;Vector3f qvec crossProduct(tvec, v0v1);v dotProduct(dir, qvec) * invDet;if (v 0 || u v 1) return false;tnear dotProduct(v0v2, qvec) * invDet;return tnear 0; }结果 作业答案 本次作业的答案放在的git仓库中作业地址
http://www.dnsts.com.cn/news/236960.html

相关文章:

  • 网站备案时间周期一般多久手机模块网站
  • 柠檬网络科技网站建设增城网站怎么做seo
  • 鞍山市建设局网站东莞热的建设网站
  • 网站后台登录界面代码自贡住房和城乡建设厅网站
  • 南宁优质手机网站建设公司学校网站建设信息
  • 12306网站建设超30亿郑州专业做网站
  • 网站建设公司服务公司如何学做网站
  • 韶关市住房和城乡建设部网站wordpress+极简博客
  • 姜堰网站建设小程序开发费用一览表fhq华网天下
  • 现在网站建设都用什么语言西安seo排名外包
  • 企业名录搜索软件现在那个能用谷歌外贸seo
  • 深圳专业的网站制作公司wordpress如何添加远程数据库
  • phpwind怎么做网站小程序公司
  • 称多县公司网站建设小众做的好的网站
  • 网站留言板块怎么做网站建设服务网络服务
  • 网站名查找网站建设平台讯息
  • 深圳专业建站多少钱wordpress增加小工具
  • 福建网站建设制作观澜小学网站建设
  • 查域名网站html制作简单网页
  • 网站空间是虚拟机吗网站每月流量
  • 免费进入正能量的网站wordpress远程调用cdn
  • 论坛网站开发中遇到的问题注册公司要求什么条件
  • 网站被提示危险网站高手总结wordpress函数
  • 网站建设与运营的论文网站推广广告 优帮云
  • 牟平建设局网站潍坊住房与城市建设部网站
  • 怀化火车站网站随机网站生成器
  • 戚墅堰常州做网站wordpress 底部美化
  • 快速免费建网站太原网站制作网页
  • 做电影网站资源哪里来的免费做网站软件下载
  • 六安公司做网站化妆品网站推广策划书