- type
- r3D_Float = TGLFloat;
- TR3D_Vector3f = record
- x, y, z: r3D_Float;
- end;
- TR3D_PlaneSide = (psYZ, psXZ, psXY);
- TR3D_Plane = record
- x,
- y,
- z,
- d : r3D_Float;
- end;
- function PlaneContruct(va : array of TR3D_Vector3f) : TR3D_Plane;
- var
- N : TR3D_Vector3f;
- begin
- N := Normal(va);
- Result.x := N.x;
- Result.y := N.y;
- Result.z := N.z;
- Result.d := PlaneDistance(N, va[0]);
- end;
- function PlaneSide(p : TR3D_Plane) : TR3D_PlaneSide;
- begin
- if (Abs(p.x) > Abs(p.y)) and (Abs(p.x) > Abs(p.z)) then
- Result := psYZ;
- if (Abs(p.y) > Abs(p.x)) and (Abs(p.y) > Abs(p.z)) then
- Result := psXZ;
- if (Abs(p.z) > Abs(p.x)) and (Abs(p.z) > Abs(p.y)) then
- Result := psXY;
- end;
- function PlaneDistance(Normal, Point: TR3D_Vector3f) : r3D_Float;
- var
- distance : r3D_Float;
- begin
- distance := 0;
- distance := - ((Normal.x * Point.x) + (Normal.y * Point.y) + (Normal.z * Point.z));
- result := distance;
- end;
- function Vector3(X,Y,Z: r3D_Float) : TR3D_Vector3f;
- begin
- Result.x := X;
- Result.y := Y;
- Result.z := Z;
- end;
- // *****************************************+
- procedure PlaneBerechnen;
- var
- Triangle : array [0..2] of TR3D_Vector3f;
- VPlane : TR3D_Plane;
- VPlaneSide : TR3D_PlaneSide;
- begin
- Triangle[0] := Vector3(-1.0,-1.0,0.0);
- Triangle[1] := Vector3(0.0,1.0,0.0);
- Triangle[2] := Vector3(1.0,-1.0,0.0);
- VPlane := PlaneContruct(Triangle;
- VPlaneSide := PlaneSide(VPlane);
- end;