cocos creator 向量


/**
        !#en
        Constructor
        see {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} or {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
        !#zh
        構造函數,可查看 {{#crossLink "cc/vec2:method"}}cc.v2{{/crossLink}} 或者 {{#crossLink "cc/p:method"}}cc.p{{/crossLink}}
        @param x x
        @param y y 
        */
        constructor(x?: number, y?: number);        
        x: number;      
        y: number;      
        /**
        !#en clone a Vec2 object
        !#zh 克隆一個 Vec2 對象 
        */
        clone(): Vec2;      
        /**
        !#en Sets vector with another's value
        !#zh 設置向量值。
        @param newValue !#en new value to set. !#zh 要設置的新值 
        */
        set(newValue: Vec2): Vec2;      
        /**
        !#en Check whether two vector equal
        !#zh 當前的向量是否與指定的向量相等。
        @param other other 
        */
        equals(other: Vec2): boolean;       
        /**
        !#en Check whether two vector equal with some degree of variance.
        !#zh
        近似判斷兩個點是否相等。<br/>
        判斷 2 個向量是否在指定數值的范圍之內,如果在則返回 true,反之則返回 false。
        @param other other
        @param variance variance 
        */
        fuzzyEquals(other: Vec2, variance: number): boolean;        
        /**
        !#en Transform to string with vector informations
        !#zh 轉換為方便閱讀的字符串。 
        */
        toString(): string;     
        /**
        !#en Calculate linear interpolation result between this vector and another one with given ratio
        !#zh 線性插值。
        @param to to
        @param ratio the interpolation coefficient
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created 
        */
        lerp(to: Vec2, ratio: number, out?: Vec2): Vec2;        
        /**
        !#en Clamp the vector between from float and to float.
        !#zh
        返回指定限制區域后的向量。<br/>
        向量大於 max_inclusive 則返回 max_inclusive。<br/>
        向量小於 min_inclusive 則返回 min_inclusive。<br/>
        否則返回自身。
        @param min_inclusive min_inclusive
        @param max_inclusive max_inclusive
        
        @example 
        ```js
        var min_inclusive = cc.v2(0, 0);
        var max_inclusive = cc.v2(20, 20);
        var v1 = cc.v2(20, 20).clampf(min_inclusive, max_inclusive); // Vec2 {x: 20, y: 20};
        var v2 = cc.v2(0, 0).clampf(min_inclusive, max_inclusive);   // Vec2 {x: 0, y: 0};
        var v3 = cc.v2(10, 10).clampf(min_inclusive, max_inclusive); // Vec2 {x: 10, y: 10};
        ``` 
        */
        clampf(min_inclusive: Vec2, max_inclusive: Vec2): Vec2;     
        /**
        !#en Adds this vector. If you want to save result to another vector, use add() instead.
        !#zh 向量加法。如果你想保存結果到另一個向量,使用 add() 代替。
        @param vector vector
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.addSelf(cc.v2(5, 5));// return Vec2 {x: 15, y: 15};
        ``` 
        */
        addSelf(vector: Vec2): Vec2;        
        /**
        !#en Adds two vectors, and returns the new result.
        !#zh 向量加法,並返回新結果。
        @param vector vector
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.add(cc.v2(5, 5));      // return Vec2 {x: 15, y: 15};
        var v1;
        v.add(cc.v2(5, 5), v1);  // return Vec2 {x: 15, y: 15};
        ``` 
        */
        add(vector: Vec2, out?: Vec2): Vec2;        
        /**
        !#en Subtracts one vector from this. If you want to save result to another vector, use sub() instead.
        !#zh 向量減法。如果你想保存結果到另一個向量,可使用 sub() 代替。
        @param vector vector
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.subSelf(cc.v2(5, 5));// return Vec2 {x: 5, y: 5};
        ``` 
        */
        subSelf(vector: Vec2): Vec2;        
        /**
        !#en Subtracts one vector from this, and returns the new result.
        !#zh 向量減法,並返回新結果。
        @param vector vector
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.sub(cc.v2(5, 5));      // return Vec2 {x: 5, y: 5};
        var v1;
        v.sub(cc.v2(5, 5), v1);  // return Vec2 {x: 5, y: 5};
        ``` 
        */
        sub(vector: Vec2, out?: Vec2): Vec2;        
        /**
        !#en Multiplies this by a number. If you want to save result to another vector, use mul() instead.
        !#zh 縮放當前向量。如果你想結果保存到另一個向量,可使用 mul() 代替。
        @param num num
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.mulSelf(5);// return Vec2 {x: 50, y: 50};
        ``` 
        */
        mulSelf(num: number): Vec2;     
        /**
        !#en Multiplies by a number, and returns the new result.
        !#zh 縮放向量,並返回新結果。
        @param num num
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.mul(5);      // return Vec2 {x: 50, y: 50};
        var v1;
        v.mul(5, v1);  // return Vec2 {x: 50, y: 50};
        ``` 
        */
        mul(num: number, out?: Vec2): Vec2;     
        /**
        !#en Multiplies two vectors.
        !#zh 分量相乘。
        @param vector vector
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.scaleSelf(cc.v2(5, 5));// return Vec2 {x: 50, y: 50};
        ``` 
        */
        scaleSelf(vector: Vec2): Vec2;      
        /**
        !#en Multiplies two vectors, and returns the new result.
        !#zh 分量相乘,並返回新的結果。
        @param vector vector
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.scale(cc.v2(5, 5));      // return Vec2 {x: 50, y: 50};
        var v1;
        v.scale(cc.v2(5, 5), v1);  // return Vec2 {x: 50, y: 50};
        ``` 
        */
        scale(vector: Vec2, out?: Vec2): Vec2;      
        /**
        !#en Divides by a number. If you want to save result to another vector, use div() instead.
        !#zh 向量除法。如果你想結果保存到另一個向量,可使用 div() 代替。
        @param num num
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.divSelf(5); // return Vec2 {x: 2, y: 2};
        ``` 
        */
        divSelf(num: number): Vec2;     
        /**
        !#en Divides by a number, and returns the new result.
        !#zh 向量除法,並返回新的結果。
        @param num num
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.div(5);      // return Vec2 {x: 2, y: 2};
        var v1;
        v.div(5, v1);  // return Vec2 {x: 2, y: 2};
        ``` 
        */
        div(num: number, out?: Vec2): Vec2;     
        /**
        !#en Negates the components. If you want to save result to another vector, use neg() instead.
        !#zh 向量取反。如果你想結果保存到另一個向量,可使用 neg() 代替。
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.negSelf(); // return Vec2 {x: -10, y: -10};
        ``` 
        */
        negSelf(): Vec2;        
        /**
        !#en Negates the components, and returns the new result.
        !#zh 返回取反后的新向量。
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        var v1;
        v.neg(v1);  // return Vec2 {x: -10, y: -10};
        ``` 
        */
        neg(out?: Vec2): Vec2;      
        /**
        !#en Dot product
        !#zh 當前向量與指定向量進行點乘。
        @param vector vector
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.dot(cc.v2(5, 5)); // return 100;
        ``` 
        */
        dot(vector?: Vec2): number;     
        /**
        !#en Cross product
        !#zh 當前向量與指定向量進行叉乘。
        @param vector vector
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.cross(cc.v2(5, 5)); // return 0;
        ``` 
        */
        cross(vector?: Vec2): number;       
        /**
        !#en Returns the length of this vector.
        !#zh 返回該向量的長度。
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.mag(); // return 14.142135623730951;
        ``` 
        */
        mag(): number;      
        /**
        !#en Returns the squared length of this vector.
        !#zh 返回該向量的長度平方。
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.magSqr(); // return 200;
        ``` 
        */
        magSqr(): number;       
        /**
        !#en Make the length of this vector to 1.
        !#zh 向量歸一化,讓這個向量的長度為 1。
        
        @example 
        ```js
        var v = cc.v2(10, 10);
        v.normalizeSelf(); // return Vec2 {x: 0.7071067811865475, y: 0.7071067811865475};
        ``` 
        */
        normalizeSelf(): Vec2;      
        /**
        !#en
        Returns this vector with a magnitude of 1.<br/>
        <br/>
        Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.
        !#zh
        返回歸一化后的向量。<br/>
        <br/>
        注意,當前向量不變,並返回一個新的歸一化向量。如果你想來歸一化當前向量,可使用 normalizeSelf 函數。
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created 
        */
        normalize(out?: Vec2): Vec2;        
        /**
        !#en Get angle in radian between this and vector.
        !#zh 夾角的弧度。
        @param vector vector 
        */
        angle(vector: Vec2): number;        
        /**
        !#en Get angle in radian between this and vector with direction.
        !#zh 帶方向的夾角的弧度。
        @param vector vector 
        */
        signAngle(vector: Vec2): number;        
        /**
        !#en rotate
        !#zh 返回旋轉給定弧度后的新向量。
        @param radians radians
        @param out optional, the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created 
        */
        rotate(radians: number, out?: Vec2): Vec2;      
        /**
        !#en rotate self
        !#zh 按指定弧度旋轉向量。
        @param radians radians 
        */
        rotateSelf(radians: number): Vec2;      
        /**
        !#en Calculates the projection of the current vector over the given vector.
        !#zh 返回當前向量在指定 vector 向量上的投影向量。
        @param vector vector
        
        @example 
        ```js
        var v1 = cc.v2(20, 20);
        var v2 = cc.v2(5, 5);
        v1.project(v2); // Vec2 {x: 20, y: 20};
        ``` 
        */
        project(vector: Vec2): Vec2;        
        /**
        Transforms the vec2 with a mat4. 3rd vector component is implicitly '0', 4th vector component is implicitly '1'
        @param m matrix to transform with
        @param out the receiving vector, you can pass the same vec2 to save result to itself, if not provided, a new vec2 will be created 
        */
        transformMat4(m: Mat4, out?: Vec2): Vec2;       
        /** !#en return a Vec2 object with x = 1 and y = 1.
        !#zh 新 Vec2 對象。 */
        static ONE: Vec2;       
        /** !#en return a Vec2 object with x = 0 and y = 0.
        !#zh 返回 x = 0 和 y = 0 的 Vec2 對象。 */
        static ZERO: Vec2;      
        /** !#en return a Vec2 object with x = 0 and y = 1.
        !#zh 返回 x = 0 和 y = 1 的 Vec2 對象。 */
        static UP: Vec2;        
        /** !#en return a Vec2 object with x = 1 and y = 0.
        !#zh 返回 x = 1 和 y = 0 的 Vec2 對象。 */
        static RIGHT: Vec2; 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM