 |
OpendTect
6.6
|
Go to the documentation of this file.
28 double& weight_a,
double& weight_b,
double& weight_c )
32 const double triarea = ba.
cross( ca ).
abs()*0.5;
40 const double distpa = pa.
abs();
43 weight_a = 1.; weight_b = 0.; weight_c = 0.;
47 const double distpb = pb.
abs();
50 weight_a = 0.; weight_b = 1.; weight_c = 0.;
54 const double distpc = pc.
abs();
57 weight_a = 0.; weight_b = 0.; weight_c = 1.;
61 const double totalinversedist = 1./distpa + 1./distpb + 1./distpc;
62 weight_a = 1./(distpa*totalinversedist);
63 weight_b = 1./(distpb*totalinversedist);
64 weight_c = 1./(distpc*totalinversedist);
68 const double triareapab = pa.
cross( pb ).
abs()*0.5;
69 const double triareapac = pa.
cross( pc ).
abs()*0.5;
70 const double triareapcb = pc.
cross( pb ).
abs()*0.5;
72 weight_a = triareapcb / triarea;
73 weight_b = triareapac / triarea;
74 weight_c = triareapab / triarea;
87 return v[0]*(v[4]*v[8]-v[5]*v[7])+v[1]*(v[5]*v[6]-v[3]*v[8])+
88 v[2]*(v[3]*v[7]-v[4]*v[6]);
97 const double d0[9] = { r1.
y, r1.
z, 1, r2.
y, r2.
z, 1, r3.
y, r3.
z, 1 };
98 const double d1[9] = { r1.
x, r1.
z, 1, r2.
x, r2.
z, 1, r3.
x, r3.
z, 1 };
99 const double d2[9] = { r1.
x, r1.
y, 1, r2.
x, r2.
y, 1, r3.
x, r3.
y, 1 };
100 const double d3[9] = { r1.
x, r1.
y, r1.
z, r2.
x, r2.
y, r2.
z, r3.
x, r3.
y,r3.
z};
107 const double* r2,
const double* r3 )
109 const double d0[9] = { r1[1], r1[2], r1[3], r2[1], r2[2], r2[3],
110 r3[1], r3[2], r3[3] };
111 const double d1[9] = { r1[0], r1[2], r1[3], r2[0], r2[2], r2[3],
112 r3[0], r3[2], r3[3] };
113 const double d2[9] = { r1[0], r1[1], r1[3], r2[0], r2[1], r2[3],
114 r3[0], r3[1], r3[3] };
115 const double d3[9] = { r1[0], r1[1], r1[2], r2[0], r2[1], r2[2],
116 r3[0], r3[1], r3[2] };
126 const Coord d12 = p1-p2;
127 const Coord d13 = p1-p3;
128 const Coord d = p1-pt;
129 const double deter=d13.
x*d12.
y-d13.
y*d12.
x;
130 const double a12 = ( p1.
dot(p1)-p2.dot(p2) )/2;
131 const double a13 = ( p1.
dot(p1)-p3.dot(p3) )/2;
132 center.
x = (a13*d12.
y-a12*d13.
y)/deter;
133 center.
y = (d13.
x*a12-d12.
x*a13)/deter;
134 return pt.sqAbs()-p1.
sqAbs()+2*center.
dot(d)<0;
145 const double t[9] = { ab.
x, ab.
y, ab.
z, ac.
x, ac.
y, ac.
z, ad.
x, ad.
y, ad.
z};
148 const double sqra = a.
x*a.
x+a.
y*a.
y+a.
z*a.
z;
149 const double d0 = (sqra-(b.x*b.x+b.y*b.y+b.z*b.z))/2;
150 const double d1 = (sqra-(c.x*c.x+c.y*c.y+c.z*c.z))/2;
151 const double d2 = (sqra-(d.x*d.x+d.y*d.y+d.z*d.z))/2;
152 const double t0[9] = { d0, ab.
y, ab.
z, d1, ac.
y, ac.
z, d2, ad.
y, ad.
z };
153 const double t1[9] = { ab.
x, d0, ab.
z, ac.
x, d1, ac.
z, ad.
x, d2, ad.
z };
154 const double t2[9] = { ab.
x, ab.
y, d0, ac.
x, ac.
y, d1, ad.
x, ad.
y, d2 };
159 return (p.
x*p.
x+p.
y*p.
y+p.
z*p.
z-sqra+
160 2*(centerx*(a.
x-p.
x)+centery*(a.
y-p.
y)+centerz*(a.
z-p.
z)))<0;
166 const Coord& a,
const Coord& b,
double epsilon )
168 double xdiff = b.
x-a.
x;
169 double ydiff = b.
y-a.
y;
170 return ((p1.
x-a.
x)*ydiff-(p1.
y-a.
y)*xdiff)*
171 ((p2.
x-a.
x)*ydiff-(p2.
y-a.
y)*xdiff)>=-epsilon;
179 const Coord3 cpp1 = (b-a).cross(p1-a);
180 const Coord3 cpp2 = (b-a).cross(p2-a);
181 return cpp1.
dot(cpp2)>=-epsilon;
187 const Coord& c,
double epsilon )
189 if ( (p.
x>a.
x && p.
x>b.
x && p.
x>c.
x) || (p.
x<a.
x && p.
x<b.
x && p.
x<c.
x) ||
190 (p.
y>a.
y && p.
y>b.
y && p.
y>c.
y) || (p.
y<a.
y && p.
y<b.
y && p.
y<c.
y) )
201 bool useangularmethod )
203 if ( !useangularmethod )
216 const double d1 = ap.
dot( bp );
217 const double d2 = bp.
dot( cp );
218 const double d3 = cp.
dot( ap );
235 const Coord pa = p-a;
236 const Coord ba = b-a;
237 const double t = pa.
dot(ba)/ba.
sqAbs();
242 const Coord pq = p-intersectpt;
243 return pq.
sqAbs()<epsilon*epsilon;
252 const double t = pa.
dot(ba)/ba.
sqAbs();
256 const Coord3 pq = pa-t*ba;
257 return pq.
sqAbs()<epsilon*epsilon;
267 const int nrvertices = plgknots.size();
270 const double newepsilon = plgknots[0].distTo(plgknots[1])*0.001;
271 return pointOnEdge3D( pt, plgknots[0], plgknots[1], newepsilon );
273 else if ( nrvertices==3 )
279 double anglesum = 0, cosangle;
280 for (
int idx=0; idx<nrvertices; idx++ )
282 p1 = plgknots[idx] - pt;
283 p2 = plgknots[(idx+1)%nrvertices] - pt;
285 const double d1 = p1.
abs();
286 const double d2 = p2.
abs();
287 if ( d1*d2 <= epsilon*epsilon || d1 <= epsilon || d2 <= epsilon )
290 cosangle = p1.
dot(p2) / (d1*d2);
292 anglesum += acos( cosangle );
295 return mIsEqual( anglesum, 6.2831853071795862, 1e-4 );
316 bool checkforundefs );
399 Line2(
double slope=0,
double intcpt=0);
444 Line3(
double x0,
double y0,
double z0,
445 double alpha,
double beta,
double gamma );
450 const Vector3 res( alpha_, beta_, gamma_ );
451 return normalize ? res.
normalize() : res;
466 double& t_line )
const;
514 bool wichside=
false )
const;
585 : radius(r),theta(t),phi(p) {}
588 : radius((float) crd.x),theta((float) crd.y)
589 , phi((float) crd.z) {}
592 {
return !(oth == *
this); }
615 const float dp =
phi-s.
phi;
630 const Coord3 edge1 = trVert1 - trVert0;
631 const Coord3 edge2 = trVert2 - trVert0;
632 const Coord3 seg = segEnd - segStart;
634 const double a = edge1.
dot( h );
638 const double f = 1.0/a;
639 const Coord3 s = segStart - trVert0;
640 const double u = f * s.
dot( h );
641 if ( u<0.0 || u>1.0 )
645 const double v = f * seg.
dot( q ) ;
646 if ( v<0.0 || u+v>1.0 )
649 const double t = f * edge2.
dot( q );
651 return res = segStart + seg * t;
Coord3 transform(const Coord &) const
Defines a 2D coordinate system on a 3D plane and transforms between the 3D space and the coordinate s...
Definition: trigonometry.h:543
A cartesian coordinate in 3D space.
Definition: coord.h:72
double determinent44(const Coord3 &r0, const Coord3 &r1, const Coord3 &r2, const Coord3 &r3)
Definition: trigonometry.h:94
Quaternion operator-(const Quaternion &) const
void set(const Coord3 &, const Coord3 &, const Coord3 &)
double distanceToPoint(const Coord &) const
Coord3 rotate(const Coord3 &) const
bool getParallelLine(Line2 &line, double dist) const
bool sameSide2D(const Coord &p1, const Coord &p2, const Coord &a, const Coord &b, double epsilon)
Definition: trigonometry.h:165
bool isNull() const
compares with epsilon
bool isOnLine(const Coord &pt) const
ParamLine2(double slope=0, double intcpt=0)
bool getPerpendicularLine(Line2 &line, const Coord &pt) const
double s_
Definition: trigonometry.h:347
Coord3 vec01_
Definition: trigonometry.h:571
Line3(const Coord3 &, const Vector3 &)
#define mGlobal(module)
Definition: commondefs.h:180
static const Coord3 & udf()
#define mIsEqual(x, y, eps)
Definition: commondefs.h:67
TypeSet< Vector3 > * makeSphereVectorSet(double dangle)
Divides a sphere in a number of vectors, divided by approximately dangle from each other....
Plane3(const Coord3 &, const Coord3 &, const Coord3 &)
Coord start_
Definition: trigonometry.h:427
bool pointInTriangle3D(const Coord3 &p, const Coord3 &a, const Coord3 &b, const Coord3 &c, double epsilon, bool useangularmethod)
Definition: trigonometry.h:199
Quaternion(const Vector3 &axis, float angle)
OrdType z
Definition: coord.h:124
double B_
Definition: trigonometry.h:531
bool operator==(const Sphere &) const
Definition: trigonometry.h:611
bool pointOnEdge3D(const Coord3 &p, const Coord3 &a, const Coord3 &b, double epsilon)
Definition: trigonometry.h:247
Quaternion & operator+=(const Quaternion &)
Quaternion & operator-=(const Quaternion &)
Coord stop_
Definition: trigonometry.h:428
void interpolateOnTriangle2D(const Coord pt, const Coord a, const Coord b, const Coord c, double &weight_a, double &weight_b, double &weight_c)
Given a point pt in a triangle ABC, we calculate the interpolation weights for each vertex.
Definition: trigonometry.h:26
#define mExpClass(module)
Definition: commondefs.h:177
Line2(const Coord &, const Coord &)
bool isInsideCircumSphere(const Coord3 &p, const Coord3 &a, const Coord3 &b, const Coord3 &c, const Coord3 &d)
Definition: trigonometry.h:139
double x0_
Definition: trigonometry.h:384
double beta_
Definition: trigonometry.h:474
bool onSameSide(const Coord3 &p1, const Coord3 &p2)
Quaternion(double s, double x, double y, double z)
#define mDefEps
Definition: commondefs.h:71
A ParamLine2 is a line in space, with the following equations:
Definition: trigonometry.h:362
A Line2 is a line on XY-plane, and it is defined in slope-intercept form y = slope*x + y-intercept; f...
Definition: trigonometry.h:397
double sqDistanceToPoint(const Coord &) const
Coord3 spherical2Cartesian(const Sphere &, bool math)
bool operator==(const ParamLine2 &) const
double gamma_
Definition: trigonometry.h:475
bool operator==(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:81
Vector3 direction(bool normalize=true) const
Definition: trigonometry.h:448
Line2(double slope=0, double intcpt=0)
double y0_
Definition: trigonometry.h:471
double D_
Definition: trigonometry.h:533
Plane3CoordSystem(const Coord3 &normal, const Coord3 &origin, const Coord3 &pt10)
Quaternion operator*(const Quaternion &) const
const Plane3 plane_
Definition: trigonometry.h:568
Quaternion & operator*=(const Quaternion &)
Coord3 normal() const
Definition: trigonometry.h:511
#define M_2PI
Definition: commondefs.h:83
double yintcpt_
Definition: trigonometry.h:422
A cartesian coordinate in 2D space.
Definition: coord.h:25
Coord3 lineSegmentIntersectsTriangle(Coord3 segStart, Coord3 segEnd, Coord3 trVert0, Coord3 trVert1, Coord3 trVert2)
Line segment/ray triangle intersection (Moller-Trumbore algorithm). Returns Coord3::udf() if no inter...
Definition: trigonometry.h:625
bool isvertical_
Definition: trigonometry.h:424
DistType dot(const Coord3 &) const
Definition: coord.h:248
float theta
Definition: trigonometry.h:595
const Plane3 & plane() const
Definition: trigonometry.h:557
ParamLine2(const Coord &, double slope)
Line2(const Coord &, double slope)
bool sameSide3D(const Coord3 &p1, const Coord3 &p2, const Coord3 &a, const Coord3 &b, double epsilon)
Definition: trigonometry.h:176
double y0_
Definition: trigonometry.h:385
bool operator==(const Line2 &) const
double distanceToPoint(const Coord3 &, bool wichside=false) const
double beta_
Definition: trigonometry.h:387
Coord3 estimateAverageVector(const TypeSet< Coord3 > &, bool normalize, bool checkforundefs)
Computes an average of a number of vectors using:
double closestPoint(const Coord3 &point) const
#define mIsZero(x, eps)
Definition: commondefs.h:66
Coord3 getProjection(const Coord3 &pos)
double sqDistanceToPoint(const Coord3 &point) const
bool pointOnEdge2D(const Coord &p, const Coord &a, const Coord &b, double epsilon)
Definition: trigonometry.h:232
bool operator!=(const ArrayNDInfo &a1, const ArrayNDInfo &a2)
Definition: arrayndinfo.h:90
Vector3 vec_
Definition: trigonometry.h:348
const Coord3 origin_
Definition: trigonometry.h:569
Coord intersection(const Line2 &, bool checkinlimit=true) const
float radius
Definition: trigonometry.h:594
float set(const TypeSet< Coord3 > &)
Coord3 getPoint(double t) const
A Line3 is a line in space, with the following equations:
Definition: trigonometry.h:441
Coord3 cross(const Coord3 &) const
Definition: coord.h:252
Plane3(double, double, double, double)
Coord3 normalize() const
Definition: coord.h:256
A Plane3 is a plane in space, with the equation: Ax + By + Cz + D = 0.
Definition: trigonometry.h:484
float phi
Definition: trigonometry.h:596
T sqAbs() const
Definition: geometry.h:381
static const Sphere & nullSphere()
Quaternion is an extension to complex numbers.
Definition: trigonometry.h:328
bool isInsideCircle(const Coord &pt, const Coord &p1, const Coord &p2, const Coord &p3)
Definition: trigonometry.h:122
double distanceToPoint(const Coord3 &point) const
double z0_
Definition: trigonometry.h:472
OrdType dot(const Coord &) const
Coord getPoint(double t) const
bool intersectWith(const Line3 &, Coord3 &) const
Plane3(const TypeSet< Coord3 > &)
bool pointInPolygon(const Coord3 &pt, const TypeSet< Coord3 > &plgknots, double epsilon)
Definition: trigonometry.h:264
Sphere(float r=0, float t=0, float p=0)
Definition: trigonometry.h:584
T y
Definition: geometry.h:68
Coord3 vec10_
Definition: trigonometry.h:570
double alpha_
Definition: trigonometry.h:473
Sphere(const Coord3 &crd)
Definition: trigonometry.h:587
void setRotation(const Vector3 &axis, float angle)
bool isok_
Definition: trigonometry.h:572
bool operator!=(const Plane3 &) const
T x
Definition: geometry.h:67
Plane3(const Coord3 &vectors, const Coord3 &, bool twovectors)
double determinent33(const double *v)
Here are some commonly used functions to judge the position relation between point and line,...
Definition: trigonometry.h:85
virtual ~Plane3CoordSystem()
Definition: trigonometry.h:552
double x0_
Definition: trigonometry.h:470
void getRotation(Vector3 &axis, float &angle) const
Represents a point in spherical coordinates. The angle phi lies in the horizontal plane,...
Definition: trigonometry.h:582
bool pointInTriangle2D(const Coord &p, const Coord &a, const Coord &b, const Coord &c, double epsilon)
Definition: trigonometry.h:186
void closestPoint(const Line3 &line, double &t_this, double &t_line) const
Coord transform(const Coord3 &, bool project) const
double C_
Definition: trigonometry.h:532
Coord closestPoint(const Coord &point) const
ParamLine2(const Coord &p0, const Coord &p1)
Quaternion inverse() const
bool intersectWith(const Plane3 &, double &t) const
double closestPoint(const Coord &point) const
Sphere cartesian2Spherical(const Coord3 &, bool math)
double xintcpt_
Definition: trigonometry.h:425
void set(const Coord3 &vector, const Coord3 &, bool twovectors)
bool intersectWith(const Plane3 &, Line3 &) const
double slope_
Definition: trigonometry.h:421
double distanceTo(const Line2 &) const
double A_
Definition: trigonometry.h:530
Coord direction(bool normalized=true) const
Coord3 Vector3
Definition: trigonometry.h:300
Line3(double x0, double y0, double z0, double alpha, double beta, double gamma)
bool operator==(const Plane3 &) const
Quaternion operator+(const Quaternion &) const
double alpha_
Definition: trigonometry.h:386
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021