class Vertex

Attributes

index[RW]
x[RW]
y[RW]
z[RW]

Public Class Methods

boundaries(vertices_list) click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 36
def self.boundaries(vertices_list)
  [
    [vertices_list.max_by(&:x).x.ceil, vertices_list.min_by(&:x).x.round],
    [vertices_list.max_by(&:y).y.ceil, vertices_list.min_by(&:y).y.round],
    [vertices_list.max_by(&:z).z.ceil, vertices_list.min_by(&:z).z.round]
  ]
end
new(x, y, z, index) click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 5
def initialize(x, y, z, index)
  @x = x
  @y = y
  @z = z
  @index = index
end
rescale(vertices, offset) click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 44
def self.rescale(vertices, offset)
  vertices.each do |v|
    v.rescale(offset)
  end
end
subset(x:, y:, z:, vertex_list:) click to toggle source

Pass functions like :negative? or :positive?

# File lib/glitch3d/objects/vertex.rb, line 51
def self.subset(x:, y:, z:, vertex_list:)
  vertex_list.select do |vertex|
    vertex.x.send(x) || vertex.y.send(y) || vertex.y.send(z)
  end
end

Public Instance Methods

fuck() click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 27
def fuck
  attr = rand_attr
  send("#{attr}=", send(attr) + Glitch3d.rand_vertex_glitch_offset)
end
max() click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 32
def max
  [@x.abs, @y.abs].max.round
end
rand_attr() click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 16
def rand_attr
  [:x, :y, :z].sample
end
rescale(_offset) click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 20
def rescale(_offset)
  [:x, :y, :z].each do |attr|
    value = send(attr)
    send("#{attr}=", value * 0.8)
  end
end
to_s() click to toggle source
# File lib/glitch3d/objects/vertex.rb, line 12
def to_s
  "v #{x} #{y} #{z}"
end