Vector4 — Aspose.3D FOSS for Java

Properties

Vector4 là một vector 4 thành phần độ chính xác đôi. Nó là kiểu lưu trữ cho các điểm điều khiển lưới (nơi w = 1.0 cho vị trí) và cho dữ liệu pháp tuyến trong VertexElementNormal các lớp (nơi w không được sử dụng).

Properties: com.aspose.threed

import com.aspose.threed.*;

Vector4 point = new Vector4(1.0, 2.0, 3.0, 1.0);

Properties

PropertiesProperties
Vector4()Properties (0, 0, 0, 1)
Vector4(double x, double y, double z, double w)Khởi tạo từ bốn thành phần
Vector4(double x, double y, double z)Khởi tạo với w = 1.0
Vector4(Vector3 v3)Khởi tạo từ một Vector3 với w = 1.0
Vector4(Vector4 other)Hàm khởi tạo sao chép

Các trường công khai

Vector4 sử dụng các trường công khai để truy cập thành phần (không phải phương thức getter/setter):

PropertiesPropertiesPropertiesProperties
xdoublev.xThành phần X
ydoublev.yThành phần Y
zdoublev.zThành phần Z
wdoublev.wThành phần W (tọa độ đồng nhất)

Properties

PropertiesKiểu trả vềProperties
set(double x, double y, double z, double w)voidĐặt tất cả bốn thành phần
toVector3()Vector3Trả về một Vector3(x, y, z) bỏ w thành phần

Properties

import com.aspose.threed.*;

Mesh mesh = new Mesh();

// Add control points (w=1.0 for positions)
mesh.getControlPoints().add(new Vector4(0.0, 0.0, 0.0, 1.0));
mesh.getControlPoints().add(new Vector4(1.0, 0.0, 0.0, 1.0));
mesh.getControlPoints().add(new Vector4(0.5, 1.0, 0.0, 1.0));
mesh.createPolygon(0, 1, 2);

// Convert to Vector3
Vector4 v4 = new Vector4(1.0, 2.0, 3.0, 1.0);
Vector3 v3 = v4.toVector3();   // Vector3(1.0, 2.0, 3.0)

// Construct from Vector3
Vector3 pos = new Vector3(5.0, 0.0, 0.0);
Vector4 homogeneous = new Vector4(pos);   // w = 1.0

Xem thêm

 Tiếng Việt