本文整理汇总了TypeScript中math2d.Vector类的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector类的具体用法?TypeScript Vector怎么用?TypeScript Vector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vector类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
x: number;
y: number;
constructor(x: number, y: number);
translate(dx: number, dy: number): Vector;
}
function getLength(p: Vector): number;
}
// @filename: math2d-augment.d.ts
import * as Math2d from 'math2d';
// Augment the module
declare module 'math2d' {
// Add a method to the class
interface Vector {
reverse(): Math2d.Point;
}
}
// @filename: b.ts
/// <reference path="math2d-augment.d.ts" />
import * as m from 'math2d';
let v = new m.Vector(3, 2);
let magnitude = m.getLength(v);
let p: m.Point = v.translate(5, 5);
p = v.reverse();
var t = p.x;
示例2: constructor
}
export class Vector implements Point {
x: number;
y: number;
constructor(x: number, y: number);
translate(dx: number, dy: number): Vector;
}
export function getLength(p: Vector): number;
// @filename: math2d-augment.d.ts
import * as Math2d from 'math2d';
// Augment the module
declare module 'math2d' {
// Add a method to the class
interface Vector {
reverse(): Math2d.Point;
}
}
// @filename: a.ts
/// <reference path="node_modules/math2d/index.d.ts" />
/// <reference path="math2d-augment.d.ts" />
let v = new Math2d.Vector(3, 2);
let magnitude = Math2d.getLength(v);
let p: Math2d.Point = v.translate(5, 5);
p = v.reverse();
var t = p.x;