Class: SkippyLib::UVQ

Inherits:
Geom::Point3d
  • Object
show all
Defined in:
modules/uv.rb

Overview

Alias to make code more readable.

The SketchUp Ruby API deal with Geom::Point3d objects when it comes to UV mapping. But this can make it hard to read the intent of the code when everything is a Geom::Point3d.

Since:

  • 3.0.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, z = 1.0) ⇒ UVQ

Returns a new instance of UVQ.

Parameters:

  • x (Float)
  • y (Float)
  • z (Float) (defaults to: 1.0)

Since:

  • 3.0.0



80
81
82
# File 'modules/uv.rb', line 80

def initialize(x, y, z = 1.0)
  super(x, y, z)
end

Class Method Details

.from_uv(uv) ⇒ Object

Parameters:

  • uv (UV, Geom::Point3d)

Since:

  • 3.0.0



68
69
70
71
72
73
74
# File 'modules/uv.rb', line 68

def self.from_uv(uv)
  unless uv.z == 0.0 || uv.z == 1.0
    raise ArgumentError, "Q is not 1.0, was: #{uv.z.to_f}"
  end

  self.new(uv.x, uv.y)
end

Instance Method Details

#inspectObject

return [String]

Since:

  • 3.0.0



107
108
109
# File 'modules/uv.rb', line 107

def inspect
  "#{self.class.name}(#{x.to_f}, #{y.to_f}, #{z.to_f})"
end

#to_sObject

return [String]

Since:

  • 3.0.0



101
102
103
# File 'modules/uv.rb', line 101

def to_s
  "#{self.class.name.split('::').last}(#{x.to_f}, #{y.to_f}, #{z.to_f})"
end

#to_uvUV

Returns:

Since:

  • 3.0.0



95
96
97
# File 'modules/uv.rb', line 95

def to_uv
  UV.from_uvq(self)
end