s2js
    Preparing search index...

    Class PointBeta

    Point represents a point on the unit sphere as a normalized 3D vector. Fields should be treated as read-only. Use one of the factory methods for creation.

    incomplete

    Implements

    Index

    Constructors

    • Beta

      Creates a new normalized point from coordinates.

      This always returns a valid point. If the given coordinates can not be normalized the origin point will be returned.

      This behavior is different from the C++ construction of a S2Point from coordinates (i.e. S2Point(x, y, z)) in that in C++ they do not Normalize.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns s2.Point

    • Beta

      Point represents a point on the unit sphere as a normalized 3D vector. Fields should be treated as read-only. Use one of the factory methods for creation.

      Parameters

      Returns s2.Point

    • Beta

      Returns a unique "origin" on the sphere for operations that need a fixed reference point. In particular, this is the "point at infinity" used for point-in-polygon testing (by counting the number of edge crossings).

      It should not be a point that is commonly used in edge tests in order to avoid triggering code to handle degenerate cases (this rules out the north and south poles). It should also not be on the boundary of any low-level S2Cell for the same reason.

      Returns s2.Point

    Other

    vector: Vector
    • Beta

      Reports whether this point is similar enough to be equal to another point.

      Parameters

      Returns boolean

    • Beta

      Reports if this Point contains the other Point. (This method matches all other S2 types where the reflexive Contains method does not contain the type's name.)

      Parameters

      Returns boolean

    • Beta

      Returns a Point that is orthogonal to both p and op. This is similar to p.Cross(op) (the true cross product) except that it does a better job of ensuring orthogonality when the Point is nearly parallel to op, it returns a non-zero result even when p == op or p == -op and the result is a Point.

      It satisfies the following properties (f == PointCross):

      (1) f(p, op) != 0 for all p, op
      (2) f(op,p) == -f(p,op) unless p == op or p == -op
      (3) f(-p,op) == -f(p,op) unless p == op or p == -op
      (4) f(p,-op) == -f(p,op) unless p == op or p == -op
      

      Parameters

      Returns s2.Point

    • Beta

      Returns a unit-length vector to use as the reference direction for deciding whether a polygon with semi-open boundaries contains the given vertex "a" (see ContainsVertexQuery). The result is unit length and is guaranteed to be different from the given point "a".

      Returns s2.Point

    • Beta

      Reports the angle between two vectors with better precision when the two are nearly parallel.

      The .Angle() member function uses atan(|AxB|, A.B) to compute the angle between A and B, which can lose about half its precision when A and B are nearly (anti-)parallel.

      Kahan provides a much more stable form:

      2*atan2(| A*|B| - |A|*B |, | A*|B| + |A|*B |)
      

      Since Points are unit magnitude by construction we can simplify further:

      2*atan2(|A-B|,|A+B|)
      

      This likely can't replace Vectors Angle since it requires four magnitude calculations, each of which takes 5 operations + a square root, plus 6 operations to find the sum and difference of the vectors, for a total of 26 + 4 square roots. Vectors Angle requires 19 + 1 square root.

      Since we always have unit vectors, we can elide two of those magnitude calculations for a total of 16 + 2 square roots which is competitive with Vectors Angle performance.

      Reference: Kahan, W. (2006, Jan 11). "How Futile are Mindless Assessments of Roundoff in Floating-Point Computation?" (p. 47). https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf

      The 2 points must be normalized.

      Parameters

      Returns number

    • Beta

      Returns true if the edges OA, OB, and OC are encountered in that order while sweeping CCW around the point O.

      You can think of this as testing whether A <= B <= C with respect to the CCW ordering around O that starts at A, or equivalently, whether B is contained in the range of angles (inclusive) that starts at A and extends CCW to C. Properties:

      (1) If OrderedCCW(a,b,c,o) && OrderedCCW(b,a,c,o), then a == b
      (2) If OrderedCCW(a,b,c,o) && OrderedCCW(a,c,b,o), then b == c
      (3) If OrderedCCW(a,b,c,o) && OrderedCCW(c,b,a,o), then a == b == c
      (4) If a == b or b == c, then OrderedCCW(a,b,c,o) is true
      (5) Otherwise if a == c, then OrderedCCW(a,b,c,o) is false
      

      Parameters

      Returns boolean

    • Beta

      Returns a unit-length vector that is orthogonal to this point. Satisfies Ortho(-a) = -Ortho(a) for all a.

      Note that Vector3 also defines an "Ortho" method, but this one is preferred for use in S2 code because it explicitly tries to avoid result coordinates that are zero. (This is a performance optimization that reduces the amount of time spent in functions that handle degeneracies.)

      Parameters

      Returns s2.Point

    • Beta

      Generates a slice of points shaped as a regular polygon with the specified number of vertices, all located on a circle of the specified angular radius around the center.

      Parameters

      • center: s2.Point
      • radius: number
      • numVertices: number

      Returns s2.Point[]

    • Beta

      Generates a slice of points shaped as a regular polygon with the specified number of vertices, all on a circle of the specified angular radius around the center.

      Parameters

      • frame: Matrix3x3
      • radius: number
      • numVertices: number

      Returns s2.Point[]