本文整理匯總了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);
}