How to use the @bentley/geometry-core.Point3d function in @bentley/geometry-core

To help you get started, we’ve selected a few @bentley/geometry-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
// Display compass center mark...
    builder.setSymbology(frameColor, frameColor, 8);
    builder.addPointString([center]);

    // Display positive "X" tick...
    builder.setSymbology(xColor, xColor, 4);
    builder.addLineString([new Point3d(1.2, 0.0, 0.0), new Point3d(0.8, 0.0, 0.0)]);

    // Display negative "X" tick...
    builder.setSymbology(frameColor, frameColor, 1);
    builder.addLineString([new Point3d(-1.2, 0.0, 0.0), new Point3d(-0.8, 0.0, 0.0)]);

    // Display positive "Y" tick...
    builder.setSymbology(yColor, yColor, 4);
    builder.addLineString([new Point3d(0.0, 1.2, 0.0), new Point3d(0.0, 0.8, 0.0)]);

    // Display negative "Y" tick...
    builder.setSymbology(frameColor, frameColor, 1);
    builder.addLineString([new Point3d(0.0, -1.2, 0.0), new Point3d(0.0, -0.8, 0.0)]);

    context.addDecorationFromBuilder(builder); // add compass as world overlay decorator
  }
github imodeljs / imodeljs / core / common / src / geometry / Cartographic.ts View on Github external
yMultiplier3 = yMultiplier2 * yMultiplier;
      zMultiplier3 = zMultiplier2 * zMultiplier;

      func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1.0;

      // "denominator" here refers to the use of this expression in the velocity and acceleration
      // computations in the sections to follow.
      denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;

      const derivative = -2.0 * denominator;

      correction = func / derivative;
    } while (Math.abs(func) > 0.01);

    if (!result)
      return new Point3d(positionX * xMultiplier, positionY * yMultiplier, positionZ * zMultiplier);

    result.x = positionX * xMultiplier;
    result.y = positionY * yMultiplier;
    result.z = positionZ * zMultiplier;
    return result;
  }
github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
builder.addShape(pts);
      builder.addLineString(pts);
    }

    // Display sticky z-lock indicator as frame inset...
    if (this._fieldLocked[ItemField.Z_Item] && this.stickyZLock && vp.view.is3d()) {
      builder.setSymbology(frameColor, fillColor, 1);

      if (CompassMode.Polar === this.compassMode) {
        const ellipse = Arc3d.createXYEllipse(center, .5, .5);
        builder.addArc(ellipse, false, false);
      } else {
        const pts: Point3d[] = [
          new Point3d(-0.5, 0.5, 0.0),
          new Point3d(0.5, 0.5, 0.0),
          new Point3d(0.5, -0.5, 0.0),
          new Point3d(-0.5, -0.5, 0.0)];
        pts[4] = pts[0].clone();
        builder.addLineString(pts);
      }
    }

    // Display compass center mark...
    builder.setSymbology(frameColor, frameColor, 8);
    builder.addPointString([center]);

    // Display positive "X" tick...
    builder.setSymbology(xColor, xColor, 4);
    builder.addLineString([new Point3d(1.2, 0.0, 0.0), new Point3d(0.8, 0.0, 0.0)]);

    // Display negative "X" tick...
    builder.setSymbology(frameColor, frameColor, 1);
github imodeljs / imodeljs / test-apps / analysis-importer / src / AnalysisImporter.ts View on Github external
/** Create a simple flat mesh with 10,000 points (100x100) */
    for (let iRow = 0; iRow < nDimensions - 1; iRow++) {
      for (let iColumn = 0; iColumn < nDimensions - 1; iColumn++) {
        const quad = [Point3d.create(iRow * spacing, iColumn * spacing, 0.0),
          Point3d.create((iRow + 1) * spacing, iColumn * spacing, 0.0),
          Point3d.create((iRow + 1) * spacing, (iColumn + 1) * spacing, 0.0),
          Point3d.create(iRow * spacing, (iColumn + 1) * spacing)];
        builder.addQuadFacet(quad);
      }
    }

    const polyface = builder.claimPolyface();
    const zeroScalarData = [], zeroDisplacementData = [], radialHeightData = [], radialSlopeData = [], radialDisplacementData = [];
    const radius = nDimensions * spacing / 2.0;
    const center = new Point3d(radius, radius, 0.0);
    const maxHeight = radius / 4.0;
    const auxChannels = [];

    /** Create a radial wave - start and return to zero  */
    for (let i = 0; i < polyface.data.point.length; i++) {
      const angle = Angle.pi2Radians * polyface.data.point.distanceIndexToPoint(i, center)! / radius;
      const height = maxHeight * Math.sin(angle);
      const slope = Math.abs(Math.cos(angle));

      zeroScalarData.push(0.0);
      zeroDisplacementData.push(0.0);
      zeroDisplacementData.push(0.0);
      zeroDisplacementData.push(0.0);

      radialHeightData.push(height);
      radialSlopeData.push(slope);
github imodeljs / imodeljs / test-apps / agent-test-app / src / changeSetUtility / ChangesetGenerator.ts View on Github external
private updateTestElement(level: number, block: number) {
        const name = ChangesetGenerator._getElementName(level, block);
        const userLabel = ChangesetGenerator._getElementUserLabel(level, block, "updated");
        this.updateElement(name, userLabel, new Point3d(10, 10, 10));
    }
github imodeljs / imodeljs / test-apps / agent-test-app / src / changeSetUtility / ChangesetGenerator.ts View on Github external
private insertTestElement(level: number, block: number) {
        const name = ChangesetGenerator._getElementName(level, block);
        const userLabel = ChangesetGenerator._getElementUserLabel(level, block, "inserted");
        this.insertElement(name, userLabel, ChangesetGenerator._getElementLocation(level, block), new Point3d(5, 5, 5));
    }
github imodeljs / imodeljs / core / frontend / src / AccuDraw.ts View on Github external
if (CompassMode.Polar === mode) {
      if (!this.autoPointPlacement)
        return;

      if (this._fieldLocked[ItemField.DIST_Item] && (this._fieldLocked[ItemField.ANGLE_Item] || this.indexed & LockedStates.ANGLE_BM) && KeyinStatus.Dynamic === this._keyinStatus[index]) {
        this.fixPointPolar(vp);
        return this.sendDataPoint(this.point, vp);
      }

      return;
    }

    if (this._fieldLocked[ItemField.X_Item] && this._fieldLocked[ItemField.Y_Item]) {
      if (!this.isActive) {
        if (!vp.view.is3d() || this._fieldLocked[ItemField.Z_Item]) {
          const globalOrigin = new Point3d();

          if (vp.view.isSpatialView())
            globalOrigin.setFrom(vp.view.iModel.globalOrigin);

          return this.sendDataPoint(globalOrigin.plus(this.delta), vp);
        }

        return;
      }

      if (!this.autoPointPlacement || KeyinStatus.Dynamic !== this._keyinStatus[index])
        return;

      this.origin.plus3Scaled(this.axes.x, this.delta.x, this.axes.y, this.delta.y, this.axes.z, this.delta.z, this.point);
      return this.sendDataPoint(this.point, vp);
    }
github imodeljs / imodeljs / core / common / src / geometry / Cartographic.ts View on Github external
/** Create a new Cartographic from longitude and latitude in [Angle]($geometry)s. The values in the resulting object will be in radians.
   * @param longitude longitude.
   * @param latitude latitude.
   * @param height The height, in meters, above the ellipsoid.
   * @param result The object into which to store the result (optional)
   */
  public static fromAngles(longitude: Angle, latitude: Angle, height: number, result?: Cartographic) {
    return Cartographic.fromRadians(longitude.radians, latitude.radians, height, result);
  }

  private static _cartesianToCartographicN = new Point3d();
  private static _cartesianToCartographicP = new Point3d();
  private static _cartesianToCartographicH = new Vector3d();
  private static _wgs84OneOverRadii = new Point3d(1.0 / 6378137.0, 1.0 / 6378137.0, 1.0 / 6356752.3142451793);
  private static _wgs84OneOverRadiiSquared = new Point3d(1.0 / (6378137.0 * 6378137.0), 1.0 / (6378137.0 * 6378137.0), 1.0 / (6356752.3142451793 * 6356752.3142451793));
  private static _wgs84RadiiSquared = new Point3d(6378137.0 * 6378137.0, 6378137.0 * 6378137.0, 6356752.3142451793 * 6356752.3142451793);
  private static _wgs84CenterToleranceSquared = 0.1;
  private static _scratchN = new Vector3d();
  private static _scratchK = new Vector3d();

  /** Creates a new Cartographic from an [ECEF](https://en.wikipedia.org/wiki/ECEF) position.
   * @param cartesian The position, in ECEF, to convert to cartographic representation.
   * @param [result] The object onto which to store the result.
   * @returns The modified result parameter, new Cartographic instance if none was provided, or undefined if the cartesian is at the center of the ellipsoid.
   */
  public static fromEcef(cartesian: Point3d, result?: Cartographic): Cartographic | undefined {
    const oneOverRadii = Cartographic._wgs84OneOverRadii;
    const oneOverRadiiSquared = Cartographic._wgs84OneOverRadiiSquared;
    const centerToleranceSquared = Cartographic._wgs84CenterToleranceSquared;
    const p = Cartographic.scaleToGeodeticSurface(cartesian, oneOverRadii, oneOverRadiiSquared, centerToleranceSquared, Cartographic._cartesianToCartographicP);
github imodeljs / imodeljs / core / frontend / src / render / webgl / Matrix.ts View on Github external
public toTransform(): Transform {
    const data = this.data;
    assert(0.0 === data[3] && 0.0 === data[7] && 0.0 === data[11] && 1.0 === data[15]);
    const origin = new Point3d(data[12], data[13], data[14]);
    const rotMat = Matrix3d.createIdentity();
    for (let i = 0; i < 3; i++)
      for (let j = 0; j < 3; j++)
        rotMat.setAt(i, j, data[i + j * 4]);

    return Transform.createRefs(origin, rotMat);
  }