Vector2 — Aspose.3D FOSS for Java

Example

Vector2 je double-precision 2-component vektor sa x i y komponentama. Primarno se koristi za UV teksturne koordinate i 2D proračune.

Example: com.aspose.threed

import com.aspose.threed.*;

Vector2 uv = new Vector2(0.5, 0.75);

Example

ExampleExample
Vector2()Kreira nulti vektor (0, 0)
Vector2(double x, double y)Kreira iz dve komponente
Vector2(Vector2 other)Konstruktor kopije

Javna polja

Vector2 koristi javna polja za pristup komponentama (ne metode get/set):

ExampleExampleExampleExample
xdoublev.xX komponenta
ydoublev.yY komponenta

Izračunata svojstva

ExampleExampleExampleExample
lengthdoublegetLength()Euklidska dužina, samo za čitanje
length2doublegetLength2()Kvadrirana dužina, samo za čitanje

Example

ExampleTip povratne vrednostiExample
dot(Vector2 rhs)doubleSkalarni proizvod sa drugim Vector2
normalize()Vector2Vraća kopiju jedinične dužine
set(double x, double y)voidPostavlja obe komponente na svoje mesto
compareTo(Vector2 other)intLeksikografsko poređenje: vraća -1, 0 ili 1

Example

import com.aspose.threed.*;

Vector2 a = new Vector2(1.0, 0.0);
Vector2 b = new Vector2(0.0, 1.0);

double dot = a.dot(b);           // 0.0
Vector2 norm = a.normalize();     // Vector2(1.0, 0.0)
System.out.println(a.getLength());  // 1.0

Vidi takođe

 Српски