当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Vector3.angleTo方法代码示例

本文整理汇总了TypeScript中THREE.Vector3.angleTo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.angleTo方法的具体用法?TypeScript Vector3.angleTo怎么用?TypeScript Vector3.angleTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THREE.Vector3的用法示例。


在下文中一共展示了Vector3.angleTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getPosition

  getPosition (): HelixPosition {
    const polymer = this.polymer
    const structure = polymer.structure
    const n = polymer.residueCount
    const n3 = n - 3

    const center = new Float32Array(3 * n)
    const axis = new Float32Array(3 * n)
    const diff = new Float32Array(n)
    const radius = new Float32Array(n)
    const rise = new Float32Array(n)
    const twist = new Float32Array(n)
    const resdir = new Float32Array(3 * n)

    const r12 = new Vector3()
    const r23 = new Vector3()
    const r34 = new Vector3()

    const diff13 = new Vector3()
    const diff24 = new Vector3()

    const v1 = new Vector3()
    const v2 = new Vector3()
    const vt = new Vector3()

    const _axis = new Vector3()
    const _prevAxis = new Vector3()

    const _resdir = new Vector3()
    const _center = new Vector3(0, 0, 0)

    const type = 'trace'
    const a1 = structure.getAtomProxy()
    const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))
    const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))
    const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))

    for (let i = 0; i < n3; ++i) {
      a1.index = a2.index
      a2.index = a3.index
      a3.index = a4.index
      a4.index = polymer.getAtomIndexByType(i + 3, type)!  // TODO

      const j = 3 * i

      // ported from GROMACS src/tools/gmx_helixorient.c

      r12.subVectors(a2 as any, a1 as any)  // TODO
      r23.subVectors(a3 as any, a2 as any)  // TODO
      r34.subVectors(a4 as any, a3 as any)  // TODO

      diff13.subVectors(r12, r23)
      diff24.subVectors(r23, r34)

      _axis.crossVectors(diff13, diff24).normalize()
      _axis.toArray(axis as any, j)  // TODO

      if (i > 0) {
        diff[ i ] = _axis.angleTo(_prevAxis)
      }

      const tmp = Math.cos(diff13.angleTo(diff24))
      twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)

      const diff13Length = diff13.length()
      const diff24Length = diff24.length()

      radius[ i ] = (
        Math.sqrt(diff24Length * diff13Length) /
        // clamp, to avoid instabilities for when
        // angle between diff13 and diff24 is near 0
        Math.max(2.0, 2.0 * (1.0 - tmp))
      )

      rise[ i ] = Math.abs(r23.dot(_axis))

      //

      v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)
      v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)

      v1.subVectors(a2 as any, v1)  // TODO
      v2.subVectors(a3 as any, v2)  // TODO

      v1.toArray(center as any, j + 3)  // TODO
      v2.toArray(center as any, j + 6)  // TODO

      //

      _resdir.subVectors(a1 as any, _center)  // TODO
      _resdir.toArray(resdir as any, j)  // TODO

      _prevAxis.copy(_axis)
      _center.copy(v1)
    }

    //

    // calc axis as dir of second and third center pos
    // project first traceAtom onto axis to get first center pos
//.........这里部分代码省略.........
开发者ID:arose,项目名称:ngl,代码行数:101,代码来源:helixorient.ts


注:本文中的THREE.Vector3.angleTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。