本文整理汇总了TypeScript中THREE.Vector3.subVectors方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.subVectors方法的具体用法?TypeScript Vector3.subVectors怎么用?TypeScript Vector3.subVectors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.subVectors方法的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: update
update(world: World, control: Control) {
var beta = control.motionTracker.getBeta();
this._acceleration.copy(this._speed).divideScalar(30).clampLength(0.1, 3);
this._acceleration.applyAxisAngle(yAxis, horizontalRotation(beta));
this._speed.add(this._acceleration);
this._speed.clampLength(0, 80);
var newPos = new Vector3().addVectors(this._position, this._speed);
this._playerTracker.updateSection(newPos);
var collision = this._playerTracker.getCollision();
if (collision) {
newPos = collision;
this._speed.multiplyScalar(0.3);
newPos = this._playerTracker.getAdjusted(newPos);
this._position.copy(newPos);
} else {
newPos = this._playerTracker.getAdjusted(newPos);
this._acceleration.subVectors(newPos, this._position).sub(this._speed).clampLength(0, 5);
this._speed.add(this._acceleration);
this._position.add(this._speed);
}
this._direction.setFromUnitVectors(
new Vector3(0, 0, 1),
this._speed.clone().setY(0).setLength(1));
}
示例3: calcPlaneAngle
export function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {
const x1 = ap1.clone()
const v12 = new Vector3()
v12.subVectors(ap2 as any, ap1 as any)
const neighbours = [new Vector3(), new Vector3()]
let ni = 0
ap1.eachBondedAtom( x => {
if (ni > 1) { return }
if (x.number !== Elements.H) {
x1.index = x.index
neighbours[ni++].subVectors(x as any, ap1 as any)
}
})
if (ni === 1) {
x1.eachBondedAtom( x => {
if (ni > 1) { return }
if (x.number !== Elements.H && x.index !== ap1.index){
neighbours[ni++].subVectors(x as any, ap1 as any)
}
})
}
if (ni !== 2) {
return
}
const cp = neighbours[0].cross(neighbours[1])
return Math.abs((Math.PI / 2) - cp.angleTo(v12))
}
示例4: calcAngles
export function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {
let angles: number[] = []
const d1 = new Vector3()
const d2 = new Vector3()
d1.subVectors(ap2 as any, ap1 as any)
ap1.eachBondedAtom( x => {
if (x.number !== Elements.H) {
d2.subVectors(x as any, ap1 as any)
angles.push(d1.angleTo(d2))
}
})
return angles
}
示例5: 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
//.........这里部分代码省略.........