计算射线与平面的交点
来源:互联网 发布:广州商学院网络拓扑图 编辑:程序博客网 时间:2024/05/16 16:22
#include "stdafx.h"#include<iostream>using namespace std;struct Point3{float x;float y;float z;};struct Vector{float x;float y;float z;};struct Ray{ //一点,和一个方向向量(两点求差)确定一条射线,Point3 p0;Vector u;};struct Plane{ //一点,和一个法向量确定一个平面Point3 p1;Vector n;};float operator*(Vector v1,Vector v2){float x = v1.x*v2.x+v1.y*v2.y+v1.z*v2.z;return x;}float operator*(Vector v1, Point3 v2){float x = v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;return x;}Point3 operator*(float t, Vector v){Point3 p;p = { t*v.x, t*v.y, t*v.z };return p;}Vector operator-(Vector v1, Vector v2){Vector v3 = { v2.x-v1.x, v2.y-v1.y, v2.z-v1.z };return v3;}Point3 operator+(Point3 v1, Point3 v2){Point3 v3 = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };return v3;}Point3 operator-(Point3 v1, Point3 v2){Point3 v3 = { v2.x - v1.x, v2.y - v1.y, v2.z - v1.z };return v3;}Point3 RayPlaneIntersection(Ray ray,Plane plane){Point3 p;float t;t = (plane.n*plane.p1 - plane.n*ray.p0) / (plane.n*ray.u);p = ray.p0 + t*ray.u;return p;}int _tmain(int argc, _TCHAR* argv[]){Ray r1;Plane p1;r1 = { { 0, 0, 0 }, { 0, 1, 0 } };p1 = { { 0, 3, 0 }, { 0, -1, 0 } };Point3 pt = RayPlaneIntersection(r1, p1);cout << pt.x << " " << pt.y << " " << pt.z << endl;return 0;}
0 0
- 计算射线与平面的交点
- 计算直线与平面交点的JavaScript脚本代码
- OSG 求射线与模型的交点
- 射线与平面的相交检测
- hdu3692 三维计算几何,射线与平面交,点的旋转
- 射线与平面
- 空间直线与平面的交点
- 求空间直线与平面的交点
- 三维空间中直线与平面的交点
- 空间直线与平面的交点
- 求直线与平面的交点
- 空间直线与平面的交点
- 射线与三角面元求交点
- 求射线与线段相交的最多交点 poj 4048
- 射线和平面的交点
- 射线与平面相交判断
- 射线与平面求交
- 射线与平面的相交检测(Ray-Plane intersection test)
- java获取ip的方式,注意多级代理的方式获取
- Laravel5.3使用学习笔记---路由
- 文件遍历~递归
- Codeforces 15E
- 浅谈redis和memcached的区别
- 计算射线与平面的交点
- 致等待跳槽的人——为什么我们不建议等到年后?
- Java邮箱手机正则表达式
- cordova-plugin-datepicker 添加只选择年月的模式(android)
- 16.3 Python descriptor-property(特性)
- 无题
- Tomcat 6 —— Realm域管理
- java之旅之继承
- Android序列化技术