15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { Cartesian2 } from "../../Source/Cesium.js";
import { pointInsideTriangle } from "../../Source/Cesium.js";
 
describe("Core/pointInsideTriangle", function () {
  it("pointInsideTriangle has point inside", function () {
    expect(
      pointInsideTriangle(
        new Cartesian2(0.25, 0.25),
        Cartesian2.ZERO,
        new Cartesian2(1.0, 0.0),
        new Cartesian2(0.0, 1.0)
      )
    ).toEqual(true);
  });
 
  it("pointInsideTriangle has point outside", function () {
    expect(
      pointInsideTriangle(
        new Cartesian2(1.0, 1.0),
        Cartesian2.ZERO,
        new Cartesian2(1.0, 0.0),
        new Cartesian2(0.0, 1.0)
      )
    ).toEqual(false);
  });
 
  it("pointInsideTriangle has point outside (2)", function () {
    expect(
      pointInsideTriangle(
        new Cartesian2(0.5, -0.5),
        Cartesian2.ZERO,
        new Cartesian2(1.0, 0.0),
        new Cartesian2(0.0, 1.0)
      )
    ).toEqual(false);
  });
 
  it("pointInsideTriangle has point outside (3)", function () {
    expect(
      pointInsideTriangle(
        new Cartesian2(-0.5, 0.5),
        Cartesian2.ZERO,
        new Cartesian2(1.0, 0.0),
        new Cartesian2(0.0, 1.0)
      )
    ).toEqual(false);
  });
 
  it("pointInsideTriangle has point on corner", function () {
    expect(
      pointInsideTriangle(
        Cartesian2.ZERO,
        Cartesian2.ZERO,
        new Cartesian2(1.0, 0.0),
        new Cartesian2(0.0, 1.0)
      )
    ).toEqual(false);
  });
 
  it("pointInsideTriangle has point inside on edge", function () {
    expect(
      pointInsideTriangle(
        new Cartesian2(0.5, 0.0),
        Cartesian2.ZERO,
        new Cartesian2(1.0, 0.0),
        new Cartesian2(0.0, 1.0)
      )
    ).toEqual(false);
  });
 
  it("throws without point", function () {
    expect(function () {
      pointInsideTriangle();
    }).toThrowDeveloperError();
  });
 
  it("throws without p0", function () {
    expect(function () {
      pointInsideTriangle(new Cartesian2());
    }).toThrowDeveloperError();
  });
 
  it("throws without p1", function () {
    expect(function () {
      pointInsideTriangle(new Cartesian2(), new Cartesian2());
    }).toThrowDeveloperError();
  });
 
  it("throws without p2", function () {
    expect(function () {
      pointInsideTriangle(new Cartesian2(), new Cartesian2(), new Cartesian2());
    }).toThrowDeveloperError();
  });
});