Skip to content
Daisuke YAMAGUCHI edited this page Nov 1, 2016 · 7 revisions

要約

Siren::Vertex (バーテックス) とは、3次元の点を表わすオブジェクトです。Siren::Shape クラスの派生クラスです。

特異メソッド

new(x = 0.0, y = 0.0, z = 0.0) -> Vertex
new([x, y, z]) -> Vertex

座標 x, y, z の位置に Siren::Vertex オブジェクトを生成します。省略した後は 0.0 になります。

例)

v1 = Siren::Vertex.new
v2 = Siren::Vertex.new 1, 0, 2
pos = [5, 2, 1.5]
v3 = Siren::Vertex.new pos

インスタンスメソッド


3次元座標値を配列で返す

xyz -> [x, y, z]
to_a -> [x, y, z]

Siren::Vertex の3次元座標値を配列として返します。

例)

point = Siren.vertex [1, 2, 3]
p point.xyz  # => [1, 2, 3]
p point.to_a # => [1, 2, 3]

座標値から Vec 型を生成する

to_v -> Vec

バーテックスの3次元座標値の x, y, z 要素を持つ Vec 型のオブジェクトを返します。

例)

point = Siren.vertex [1, 2, 3]
p point.to_v # => #<Vec:0x1f9bf50 @x=1.000000, @y=2.000000, @z=3.000000>

Clone this wiki locally