本文整理汇总了TypeScript中THREE.Vector3.distanceTo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.distanceTo方法的具体用法?TypeScript Vector3.distanceTo怎么用?TypeScript Vector3.distanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.distanceTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: projectPointOnVector
structure.eachAtom(function (ap: AtomProxy) {
projectPointOnVector(p.copy(ap as any), ax1, center) // TODO
const dp1 = t.subVectors(p, center).normalize().dot(ax1)
const dt1 = p.distanceTo(center)
if (dp1 > 0) {
if (dt1 > d1a) d1a = dt1
} else {
if (dt1 > d1b) d1b = dt1
}
projectPointOnVector(p.copy(ap as any), ax2, center)
const dp2 = t.subVectors(p, center).normalize().dot(ax2)
const dt2 = p.distanceTo(center)
if (dp2 > 0) {
if (dt2 > d2a) d2a = dt2
} else {
if (dt2 > d2b) d2b = dt2
}
projectPointOnVector(p.copy(ap as any), ax3, center)
const dp3 = t.subVectors(p, center).normalize().dot(ax3)
const dt3 = p.distanceTo(center)
if (dp3 > 0) {
if (dt3 > d3a) d3a = dt3
} else {
if (dt3 > d3b) d3b = dt3
}
})
示例2: function
const cgPolymer = function (p: Polymer) {
const localAngle = 20
const centerDist = 2.0
const residueStore = p.residueStore
const offset = p.residueIndexStart
const helixbundle = new Helixbundle(p)
const pos = helixbundle.position
const c1 = new Vector3()
const c2 = new Vector3()
for (let i = 0, il = p.residueCount; i < il; ++i) {
c1.fromArray(pos.center as any, i * 3) // TODO
c2.fromArray(pos.center as any, i * 3 + 3) // TODO
const d = c1.distanceTo(c2)
if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {
residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)
residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)
}
}
}
示例3: isPointOnSegment
export function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {
const len = l1.distanceTo(l2)
return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len
}
示例4: getAxis
getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {
localAngle = localAngle || 30
centerDist = centerDist || 2.5
ssBorder = ssBorder === undefined ? false : ssBorder
const polymer = this.polymer
const structure = polymer.structure
const n = polymer.residueCount
const residueIndexStart = polymer.residueIndexStart
const pos = this.position
const cp = colorParams || {}
cp.structure = structure
const colormaker = ColormakerRegistry.getScheme(cp)
const radiusFactory = new RadiusFactory(radiusParams)
let j = 0
let k = 0
const axis: number[] = []
const center: number[] = []
const beg: number[] = []
const end: number[] = []
const col: number[] = []
const pick = []
const size = []
const residueOffset = []
const residueCount = []
let tmpAxis = new Float32Array(n * 3)
let tmpCenter = new Float32Array(n * 3)
let _axis, _center
const _beg = new Vector3()
const _end = new Vector3()
const rp1 = structure.getResidueProxy()
const rp2 = structure.getResidueProxy()
const ap = structure.getAtomProxy()
const c1 = new Vector3()
const c2 = new Vector3()
let split = false
for (let i = 0; i < n; ++i) {
rp1.index = residueIndexStart + i
c1.fromArray(pos.center as any, i * 3)
if (i === n - 1) {
split = true
} else {
rp2.index = residueIndexStart + i + 1
c2.fromArray(pos.center as any, i * 3 + 3)
if (ssBorder && rp1.sstruc !== rp2.sstruc) {
split = true
} else if (c1.distanceTo(c2) > centerDist) {
split = true
} else if (pos.bending[ i ] > localAngle) {
split = true
}
}
if (split) {
if (i - j < 4) {
j = i
split = false
continue
}
ap.index = rp1.traceAtomIndex
// ignore first and last axis
tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)
tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)
_axis = calculateMeanVector3(tmpAxis).normalize()
_center = calculateMeanVector3(tmpCenter)
_beg.fromArray(tmpCenter as any)
projectPointOnVector(_beg, _axis, _center)
_end.fromArray(tmpCenter as any, tmpCenter.length - 3)
projectPointOnVector(_end, _axis, _center)
_axis.subVectors(_end, _beg)
_axis.toArray(axis as any, k)
_center.toArray(center as any, k)
_beg.toArray(beg as any, k)
_end.toArray(end as any, k)
colormaker.atomColorToArray(ap, col, k)
pick.push(ap.index)
//.........这里部分代码省略.........
示例5: closer
function closer (x: Vector3, a: Vector3, b: Vector3) {
return x.distanceTo(a) < x.distanceTo(b)
}