Repository navigation
Expand file tree
/
Copy pathLaserMathProbe.cpp
More file actions
31 lines (31 loc) · 2.06 KB
/
Copy pathLaserMathProbe.cpp
File metadata and controls
31 lines (31 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "LaserMath.h"
#include <cstdio>
#include <limits>
using namespace LaserMath;
int main(){
View v{};v.valid=true;v.world={{1,0,0,0,1,0,0,0,1,0,0,0}};
v.projection.v[0]=v.projection.v[5]=1;v.projection.v[8]=.12f;v.projection.v[9]=-.08f;v.projection.v[10]=-1.001f;v.projection.v[11]=-1;v.projection.v[14]=-.1f;
Hit h{{0,0,-5},{0,0,1},true};float c[4][4]{};
if(!Quad(v,h,.01f,c))return 1;
float x=(c[0][0]+c[3][0])*.5f,y=(c[0][1]+c[3][1])*.5f;
if(std::abs(x/c[0][3]+.12f)>.00001f||std::abs(y/c[0][3]-.08f)>.00001f)return 2;
View r=v;r.world.v[9]=.032f;v.world.v[9]=-.032f;float a[4]{},b[4]{};
if(!Clip(v,h.position,a)||!Clip(r,h.position,b)||a[0]<=b[0])return 3;
v.world.v[9]=10;h.position.x=10;if(!Quad(v,h,.01f,c))return 4;
if(Quad(v,{{0,0,5},{0,0,1},true},.01f,c))return 5;
if(Quad(v,{{0,0,-5},{0,0,0},true},.01f,c))return 6;
for(unsigned t=0;t<=8;++t)if(Gun(t)!=(t<=5||t==7))return 7;
V direction{};if(!Direction({1,2,3},{1,7,3},direction)||std::abs(direction.y-1)>.00001f||Direction({1,2,3},{1,2,3},direction))return 8;
v.world.v[9]=-.032f;h.position.x=0;
for(float distance:{.5f,5.f,50.f,500.f})for(V normal:{V{0,0,1},V{1,0,.0001f}}){
h.position.z=-distance;h.normal=normal;float center[4]{};
if(!VisibleQuad(v,h,.007f,4000,4768,4,c)||!Clip(v,h.position,center))return 9;
for(unsigned axis=0;axis<4;++axis)if(std::abs((c[0][axis]+c[3][axis])*.5f-center[axis])>.0001f)return 10;
float rx=(c[3][0]-c[0][0])/c[0][3]*1000,ry=(c[3][1]-c[0][1])/c[0][3]*1192;
if(rx<3.999f||ry<3.999f||std::abs(c[0][2]-center[2])>.0001f)return 11;
}
h={{0,0,-5},{0,0,1},true};float old[4][4]{};
if(!Quad(v,h,.007f,old)||!VisibleQuad(v,h,.007f,4000,4768,0,c)||memcmp(old,c,sizeof(c)))return 12;
if(VisibleQuad(v,h,.007f,0,4768,4,c)||VisibleQuad(v,h,.007f,4000,4768,std::numeric_limits<float>::quiet_NaN(),c)||VisibleQuad(v,h,.007f,4000,4768,17,c))return 13;
puts("PASS: exact stereo hit centre/depth, asymmetric eyes, near/far pixel floor, grazing angles, legacy option and invalid-input rejection.");
}