0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / Intf / Intf.cxx
CommitLineData
b311480e 1// Created on: 1993-01-20
2// Created by: Didier PIFFAULT
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
42cf5bc1 17
18#include <gp_Pnt.hxx>
19#include <gp_XYZ.hxx>
20#include <Intf.hxx>
7fd59977 21
22//=======================================================================
23//function : PlaneEquation
24//purpose :
25//=======================================================================
7fd59977 26void Intf::PlaneEquation (const gp_Pnt& P1,
27 const gp_Pnt& P2,
28 const gp_Pnt& P3,
29 gp_XYZ& NormalVector,
30 Standard_Real& PolarDistance)
31{
32 gp_XYZ v1=P2.XYZ()-P1.XYZ();
33 gp_XYZ v2=P3.XYZ()-P2.XYZ();
34 gp_XYZ v3=P1.XYZ()-P3.XYZ();
35 NormalVector= (v1^v2)+(v2^v3)+(v3^v1);
df119b4e 36 Standard_Real aNormLen = NormalVector.Modulus();
37 if (aNormLen < gp::Resolution()) {
38 PolarDistance = 0.;
39 }
40 else {
41 NormalVector.Divide(aNormLen);
42 PolarDistance = NormalVector * P1.XYZ();
43 }
7fd59977 44}
45
46
47//=======================================================================
48//function : Contain
49//purpose :
50//=======================================================================
51
52Standard_Boolean Intf::Contain (const gp_Pnt& P1,
53 const gp_Pnt& P2,
54 const gp_Pnt& P3,
55 const gp_Pnt& ThePnt)
56{
57 gp_XYZ v1=(P2.XYZ()-P1.XYZ())^(ThePnt.XYZ()-P1.XYZ());
58 gp_XYZ v2=(P3.XYZ()-P2.XYZ())^(ThePnt.XYZ()-P2.XYZ());
59 gp_XYZ v3=(P1.XYZ()-P3.XYZ())^(ThePnt.XYZ()-P3.XYZ());
60 if (v1*v2 >= 0. && v2*v3 >= 0. && v3*v1>=0.) return Standard_True;
61 else return Standard_False;
62}