本文整理汇总了TypeScript中@apestaartje/geometry.vector类的典型用法代码示例。如果您正苦于以下问题:TypeScript vector类的具体用法?TypeScript vector怎么用?TypeScript vector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vector类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: drag
export function drag(k: number, velocity: geometry.vector.Vector): geometry.vector.Vector {
if (geometry.vector.length(velocity) === 0) {
return zero();
}
return geometry.vector.scale(velocity, -k);
}
示例2: gravity
export function gravity(m1: number, m2: number, v: geometry.vector.Vector, G: number = GRAVITATIONAL_CONSTANT): geometry.vector.Vector {
const distance: number = geometry.vector.length(v);
return geometry.vector.scale(
v,
-force(m1, m2, distance, G) / distance
);
}
示例3:
(sum: geometry.vector.Vector, force: geometry.vector.Vector): geometry.vector.Vector => {
return geometry.vector.add(sum, force);
},
示例4: force
export function force(radians: number, mass: number, acceleration: number): geometry.vector.Vector {
return geometry.vector.factory(radians, mass * acceleration);
}