计算射线与平面的交点

#include "stdafx.h"
#include
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, v

你可能感兴趣的:(OSG学习)