sketchup-api-stubs 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/SketchUp/Geom/BoundingBox.rb +17 -20
- data/SketchUp/Geom/Bounds2d.rb +172 -0
- data/SketchUp/Geom/LatLong.rb +31 -16
- data/SketchUp/Geom/OrientedBounds2d.rb +102 -0
- data/SketchUp/Geom/Point2d.rb +365 -0
- data/SketchUp/Geom/Point3d.rb +121 -110
- data/SketchUp/Geom/PolygonMesh.rb +30 -21
- data/SketchUp/Geom/Transformation.rb +8 -4
- data/SketchUp/Geom/Transformation2d.rb +125 -0
- data/SketchUp/Geom/UTM.rb +43 -37
- data/SketchUp/Geom/Vector2d.rb +497 -0
- data/SketchUp/Geom/Vector3d.rb +143 -131
- data/SketchUp/Layout.rb +25 -0
- data/SketchUp/Layout/AngularDimension.rb +569 -0
- data/SketchUp/Layout/AutoTextDefinition.rb +417 -0
- data/SketchUp/Layout/AutoTextDefinitions.rb +186 -0
- data/SketchUp/Layout/ConnectionPoint.rb +70 -0
- data/SketchUp/Layout/Document.rb +458 -0
- data/SketchUp/Layout/Ellipse.rb +29 -0
- data/SketchUp/Layout/Entities.rb +155 -0
- data/SketchUp/Layout/Entity.rb +363 -0
- data/SketchUp/Layout/FormattedText.rb +349 -0
- data/SketchUp/Layout/Grid.rb +131 -0
- data/SketchUp/Layout/Group.rb +261 -0
- data/SketchUp/Layout/Image.rb +86 -0
- data/SketchUp/Layout/Label.rb +371 -0
- data/SketchUp/Layout/Layer.rb +222 -0
- data/SketchUp/Layout/LayerInstance.rb +128 -0
- data/SketchUp/Layout/Layers.rb +232 -0
- data/SketchUp/Layout/LinearDimension.rb +563 -0
- data/SketchUp/Layout/LockedEntityError.rb +10 -0
- data/SketchUp/Layout/LockedLayerError.rb +11 -0
- data/SketchUp/Layout/Page.rb +187 -0
- data/SketchUp/Layout/PageInfo.rb +393 -0
- data/SketchUp/Layout/Pages.rb +216 -0
- data/SketchUp/Layout/Path.rb +326 -0
- data/SketchUp/Layout/Rectangle.rb +174 -0
- data/SketchUp/Layout/SketchUpModel.rb +522 -0
- data/SketchUp/Layout/Style.rb +1520 -0
- data/SketchUp/Layout/Table.rb +290 -0
- data/SketchUp/Layout/TableCell.rb +149 -0
- data/SketchUp/Layout/TableColumn.rb +139 -0
- data/SketchUp/Layout/TableRow.rb +135 -0
- data/SketchUp/Sketchup/Animation.rb +7 -4
- data/SketchUp/Sketchup/ArcCurve.rb +10 -10
- data/SketchUp/Sketchup/AttributeDictionaries.rb +13 -4
- data/SketchUp/Sketchup/AttributeDictionary.rb +12 -12
- data/SketchUp/Sketchup/Color.rb +68 -78
- data/SketchUp/Sketchup/ComponentDefinition.rb +60 -60
- data/SketchUp/Sketchup/ComponentInstance.rb +57 -55
- data/SketchUp/Sketchup/DefinitionList.rb +34 -17
- data/SketchUp/Sketchup/Drawingelement.rb +19 -21
- data/SketchUp/Sketchup/Edge.rb +22 -24
- data/SketchUp/Sketchup/Entities.rb +173 -162
- data/SketchUp/Sketchup/Entity.rb +71 -55
- data/SketchUp/Sketchup/Face.rb +45 -44
- data/SketchUp/Sketchup/Group.rb +47 -49
- data/SketchUp/Sketchup/Image.rb +16 -0
- data/SketchUp/Sketchup/ImageRep.rb +226 -0
- data/SketchUp/Sketchup/InstancePath.rb +13 -13
- data/SketchUp/Sketchup/Layer.rb +15 -17
- data/SketchUp/Sketchup/Material.rb +40 -30
- data/SketchUp/Sketchup/Materials.rb +40 -22
- data/SketchUp/Sketchup/Menu.rb +5 -5
- data/SketchUp/Sketchup/Model.rb +230 -228
- data/SketchUp/Sketchup/Page.rb +32 -0
- data/SketchUp/Sketchup/Pages.rb +3 -4
- data/SketchUp/Sketchup/RenderingOptions.rb +21 -16
- data/SketchUp/Sketchup/SectionPlane.rb +64 -0
- data/SketchUp/Sketchup/Selection.rb +20 -28
- data/SketchUp/Sketchup/ShadowInfo.rb +14 -14
- data/SketchUp/Sketchup/Text.rb +24 -26
- data/SketchUp/Sketchup/Texture.rb +28 -12
- data/SketchUp/Sketchup/Vertex.rb +14 -11
- data/SketchUp/Sketchup/View.rb +126 -116
- data/SketchUp/UI/Command.rb +17 -17
- data/SketchUp/UI/HtmlDialog.rb +8 -5
- data/SketchUp/UI/Notification.rb +1 -1
- data/SketchUp/UI/Toolbar.rb +13 -14
- data/SketchUp/UI/WebDialog.rb +55 -59
- data/SketchUp/_top_level.rb +139 -27
- data/SketchUp/{Array.rb → array.rb} +167 -30
- data/SketchUp/{Geom.rb → geom.rb} +9 -7
- data/SketchUp/{LanguageHandler.rb → languagehandler.rb} +15 -15
- data/SketchUp/{Length.rb → length.rb} +15 -15
- data/SketchUp/{Numeric.rb → numeric.rb} +19 -19
- data/SketchUp/sketchup.rb +167 -156
- data/SketchUp/{SketchupExtension.rb → sketchupextension.rb} +27 -27
- data/SketchUp/{String.rb → string.rb} +1 -1
- data/SketchUp/ui.rb +113 -87
- metadata +46 -9
@@ -1,17 +1,17 @@
|
|
1
1
|
# Copyright:: Copyright 2017 Trimble Inc.
|
2
2
|
# License:: The MIT License (MIT)
|
3
3
|
|
4
|
-
# The PolygonMesh class contains methods to create polygon mesh
|
5
|
-
# This is useful if you need to write a custom importer/exporter in
|
6
|
-
# works at the level of triangulated polygons. For example, you can
|
7
|
-
# the triangles that make up a 15-sided
|
8
|
-
# write a
|
9
|
-
# and draws faces based on the mesh.
|
4
|
+
# The {#Geom::PolygonMesh} class contains methods to create polygon mesh
|
5
|
+
# structures. This is useful if you need to write a custom importer/exporter in
|
6
|
+
# Ruby that works at the level of triangulated polygons. For example, you can
|
7
|
+
# determine the triangles that make up a 15-sided {#Sketchup::Face} by using
|
8
|
+
# this class, or write a {#Sketchup::Importer} that reads a data file, creates
|
9
|
+
# a mesh from it, and draws faces based on the mesh.
|
10
10
|
#
|
11
11
|
# You can construct a mesh manually using the methods of this class, or you
|
12
12
|
# can get a mesh from a face by calling the Face.mesh method. See
|
13
|
-
# Entities
|
14
|
-
# faces.
|
13
|
+
# {Sketchup::Entities#add_faces_from_mesh} for an easy way to convert a mesh
|
14
|
+
# back into faces.
|
15
15
|
#
|
16
16
|
# @example
|
17
17
|
# # Grab a mesh from a given face.
|
@@ -19,7 +19,7 @@
|
|
19
19
|
#
|
20
20
|
# # Create a new group that we will populate with the mesh.
|
21
21
|
# group = Sketchup.active_model.entities.add_group
|
22
|
-
# group.add_faces_from_mesh(my_mesh)
|
22
|
+
# group.entities.add_faces_from_mesh(my_mesh)
|
23
23
|
#
|
24
24
|
# @version SketchUp 6.0
|
25
25
|
class Geom::PolygonMesh
|
@@ -32,6 +32,11 @@ class Geom::PolygonMesh
|
|
32
32
|
SMOOTH_SOFT_EDGES = nil # Stub value.
|
33
33
|
SOFTEN_BASED_ON_INDEX = nil # Stub value.
|
34
34
|
|
35
|
+
MESH_NORMALS = nil # Stub value.
|
36
|
+
MESH_POINTS = nil # Stub value.
|
37
|
+
MESH_UVQ_BACK = nil # Stub value.
|
38
|
+
MESH_UVQ_FRONT = nil # Stub value.
|
39
|
+
|
35
40
|
# Instance Methods
|
36
41
|
|
37
42
|
# The {#add_point} method is used to add a point to the mesh.
|
@@ -272,12 +277,11 @@ class Geom::PolygonMesh
|
|
272
277
|
# The {#polygon_at} method is used to retrieve an array of vertex index values
|
273
278
|
# for a polygon at a specific index.
|
274
279
|
#
|
275
|
-
#
|
276
|
-
#
|
277
|
-
#
|
278
|
-
#
|
279
|
-
#
|
280
|
-
# get +[-1, 2,3]+ use +1+ as the argument to {#point_at}.
|
280
|
+
# values with the sign indicating a hidden edge. For example, a return value of
|
281
|
+
# +[-1, 2, 3]+ indicates that the edge from +1+ to +2+ is hidden. The negative
|
282
|
+
# values should not be used as an index for point_at, take the positive value
|
283
|
+
# of the index value in the polygon array. So if you get +[-1, 2,3]+ use +1+
|
284
|
+
# as the argument to {#point_at}.
|
281
285
|
#
|
282
286
|
# @example
|
283
287
|
# mesh = Geom::PolygonMesh.new
|
@@ -287,6 +291,8 @@ class Geom::PolygonMesh
|
|
287
291
|
# index = mesh.add_polygon(point1, point2, point3)
|
288
292
|
# polygon = mesh.polygon_at(index)
|
289
293
|
#
|
294
|
+
# @note Index is 1 based (starts at 1).The returned array can contain negative
|
295
|
+
#
|
290
296
|
# @param [Integer] index
|
291
297
|
# The index of the desired polygon.
|
292
298
|
#
|
@@ -319,14 +325,14 @@ class Geom::PolygonMesh
|
|
319
325
|
# The {#polygons} method is used to retrieve an array of all polygons in the
|
320
326
|
# mesh.
|
321
327
|
#
|
322
|
-
# The returned array can
|
323
|
-
# hidden edge. For example, a return value of +[-1, 2, 3]+
|
324
|
-
# edge from +1+ to +2+ is hidden.
|
328
|
+
# The returned array contains an array that can have a negative value with the
|
329
|
+
# sign indicating a hidden edge. For example, a return value of +[-1, 2, 3]+
|
330
|
+
# indicates that the edge from +1+ to +2+ is hidden.
|
325
331
|
#
|
326
332
|
# @example
|
327
333
|
# polygons = polygonmesh.polygons
|
328
334
|
#
|
329
|
-
# @return [Array<Integer>]
|
335
|
+
# @return [Array<Array<Integer>>, Array<nil>]
|
330
336
|
#
|
331
337
|
# @version SketchUp 6.0
|
332
338
|
def polygons
|
@@ -397,6 +403,9 @@ class Geom::PolygonMesh
|
|
397
403
|
# @note If you don't specify how many points you will be adding to the mesh
|
398
404
|
# when you initiate it you may risk the UV data becoming out of sync.
|
399
405
|
#
|
406
|
+
# @param [Boolean] front
|
407
|
+
# A boolean representing the front or back.
|
408
|
+
#
|
400
409
|
# @param [Geom::Point3d] point
|
401
410
|
# A Point3d object representing UV coordinates.
|
402
411
|
#
|
@@ -406,7 +415,7 @@ class Geom::PolygonMesh
|
|
406
415
|
# @return [nil]
|
407
416
|
#
|
408
417
|
# @version SketchUp 2014
|
409
|
-
def set_uv(index, point)
|
418
|
+
def set_uv(index, point, front)
|
410
419
|
end
|
411
420
|
|
412
421
|
# The {#transform!} method is used to apply a transformation to a mesh.
|
@@ -465,7 +474,7 @@ class Geom::PolygonMesh
|
|
465
474
|
# @example
|
466
475
|
# # Get a mesh with front and back UVs.
|
467
476
|
# mesh = face.mesh(1 | 2)
|
468
|
-
# uvs = mesh.uvs
|
477
|
+
# uvs = mesh.uvs(true)
|
469
478
|
#
|
470
479
|
# @param [Boolean] front
|
471
480
|
#
|
@@ -112,7 +112,8 @@ class Geom::Transformation
|
|
112
112
|
#
|
113
113
|
# @overload scaling(scale)
|
114
114
|
#
|
115
|
-
# @note This
|
115
|
+
# @note This has been fixed in SketchUp 2018 but in previous versions it
|
116
|
+
# might yield an unexpected transformation. It sets the 16th value
|
116
117
|
# to the scaling factor. Something not all extensions reading the
|
117
118
|
# transformation expects. Consider using +scaling(xscale, yscale, zscale)+
|
118
119
|
# instead.
|
@@ -250,9 +251,10 @@ class Geom::Transformation
|
|
250
251
|
# # Returns false.
|
251
252
|
# status = tr.identity?
|
252
253
|
#
|
253
|
-
# @note
|
254
|
-
#
|
255
|
-
#
|
254
|
+
# @note As of SketchUp 2018, this now looks at the data to determine if the
|
255
|
+
# transformation is identity. Prior to SU2018, this only looks at the flag to
|
256
|
+
# see if the transform has not been modified. If the transform has been
|
257
|
+
# changed, this will return false even if it is really the identity.
|
256
258
|
#
|
257
259
|
# @return [Boolean] +true+ if the transformation is the identity
|
258
260
|
#
|
@@ -334,6 +336,8 @@ class Geom::Transformation
|
|
334
336
|
# @overload initialize(scale)
|
335
337
|
#
|
336
338
|
# Creates a transformation that does uniform scaling.
|
339
|
+
# @note Versions prior to SU2018 would produce transformations which
|
340
|
+
# didn't always work right in SketchUp. See {.scaling} for more info.
|
337
341
|
# @param [Float] scale
|
338
342
|
# @return [Geom::Transformation]
|
339
343
|
#
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# Copyright:: Copyright 2017 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
#
|
5
|
+
# @version LayOut 2018
|
6
|
+
class Geom::Transformation2d
|
7
|
+
|
8
|
+
# Instance Methods
|
9
|
+
|
10
|
+
# The {#==} method checks to see if the two {Geom::Transformation2d}s are equal.
|
11
|
+
# This checks whether the values of the transformations are the same.
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# tr = Geom::Transformation2d.new({1.0, 0.0, 0.0, 1.0, 1.0, 1.0})
|
15
|
+
# tr == tr.clone
|
16
|
+
#
|
17
|
+
# @param [Geom::Transformation2d] other
|
18
|
+
#
|
19
|
+
# @return [Boolean]
|
20
|
+
#
|
21
|
+
# @version LayOut 2018
|
22
|
+
def ==(other)
|
23
|
+
end
|
24
|
+
|
25
|
+
# The {#clone} method creates a copy of the {Geom::Transformation2d}.
|
26
|
+
#
|
27
|
+
# @example
|
28
|
+
# tr1 = Geom::Transformation2d.new
|
29
|
+
# tr2 = tr1.clone
|
30
|
+
#
|
31
|
+
# @return [Geom::Transformation2d]
|
32
|
+
#
|
33
|
+
# @version LayOut 2018
|
34
|
+
def clone
|
35
|
+
end
|
36
|
+
|
37
|
+
# The {#identity?} method determines if the {Geom::Transformation2d} is the
|
38
|
+
# {IDENTITY_2D} transform.
|
39
|
+
#
|
40
|
+
# @example
|
41
|
+
# tr = Geom::Transformation2d.new
|
42
|
+
# # Returns true.
|
43
|
+
# status = tr.identity?
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# # Returns true.
|
47
|
+
# status = IDENTITY.identity?
|
48
|
+
#
|
49
|
+
# @example
|
50
|
+
# array = {1.0, 0.0, 0.0, 1.0, 1.0, 0.0}
|
51
|
+
# tr = Geom::Transformation2d.new(array)
|
52
|
+
# # Returns false.
|
53
|
+
# status = tr.identity?
|
54
|
+
#
|
55
|
+
# @return [Boolean] +true+ if the transform is the identity
|
56
|
+
#
|
57
|
+
# @return [Boolean]
|
58
|
+
#
|
59
|
+
# @version LayOut 2018
|
60
|
+
def identity?
|
61
|
+
end
|
62
|
+
|
63
|
+
# The {#initialize} method creates a new {Geom::Transformation2d}. You can use
|
64
|
+
# this method or one of the more specific methods for creating specific kinds
|
65
|
+
# of {Geom::Transformation2d}.
|
66
|
+
#
|
67
|
+
# @example
|
68
|
+
# tr = Geom::Transformation2d.new({1.0, 0.0, 0.0, 1.0, 1.0, 1.0})
|
69
|
+
#
|
70
|
+
# @overload initialize
|
71
|
+
#
|
72
|
+
# @return [Geom::Transformation2d] identity Transformation2d.
|
73
|
+
#
|
74
|
+
# @overload initialize(array)
|
75
|
+
#
|
76
|
+
# @param [Array<Float>] array A 6 element Array.
|
77
|
+
# @return [Geom::Transformation2d]
|
78
|
+
#
|
79
|
+
# @overload initialize(transformation)
|
80
|
+
#
|
81
|
+
# Creates a Transformation2d that is a copy of another Transformation2d.
|
82
|
+
# This is equivalent to {#clone}.
|
83
|
+
# @param [Geom::Transformation2d] transform
|
84
|
+
# @return [Geom::Transformation2d]
|
85
|
+
#
|
86
|
+
# @version LayOut 2018
|
87
|
+
def initialize(*args)
|
88
|
+
end
|
89
|
+
|
90
|
+
# The {#set!} method sets the {Geom::Transformation2d} to match another one.
|
91
|
+
# The argument is anything that can be converted into a {Geom::Transformation2d}.
|
92
|
+
#
|
93
|
+
# @example
|
94
|
+
# tr1 = Geom::Transformation2d.new
|
95
|
+
# array = {2.0, 0.0, 0.0, 2.0, 0.0, 0.0}
|
96
|
+
# tr1.set!(array)
|
97
|
+
#
|
98
|
+
# @overload set!(transformation)
|
99
|
+
#
|
100
|
+
# @param [Geom::Transformation2d] transformation
|
101
|
+
# @return [Geom::Transformation2d]
|
102
|
+
#
|
103
|
+
# @overload set!(matrix)
|
104
|
+
#
|
105
|
+
# @param [Array<Float>] matrix An array of 6 floats.
|
106
|
+
# @return [Geom::Transformation2d]
|
107
|
+
#
|
108
|
+
# @version LayOut 2018
|
109
|
+
def set!(arg)
|
110
|
+
end
|
111
|
+
|
112
|
+
# The {#to_a} method returns a 6 element array which contains the values that
|
113
|
+
# define the Transformation2d.
|
114
|
+
#
|
115
|
+
# @example
|
116
|
+
# tr = Geom::Transformation2d.new
|
117
|
+
# tr.to_a.each_slice(2) {|a| p a}
|
118
|
+
#
|
119
|
+
# @return [Array<Float>] an array of 6 elements
|
120
|
+
#
|
121
|
+
# @version LayOut 2018
|
122
|
+
def to_a
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
data/SketchUp/Geom/UTM.rb
CHANGED
@@ -3,130 +3,136 @@
|
|
3
3
|
|
4
4
|
# The UTM class lets you work with UTM map coordinates.
|
5
5
|
#
|
6
|
+
# @note Valid ranges for {#zone_number} and {#zone_letter} are 1-60 and C-X
|
7
|
+
# (omitting I and O). Valid ranges for {#x} and {#y} are 100000-899999.
|
8
|
+
#
|
6
9
|
# @version SketchUp 6.0
|
7
10
|
class Geom::UTM
|
8
11
|
|
9
12
|
# Instance Methods
|
10
13
|
|
11
|
-
# The
|
12
|
-
# UTM objects by calling the method Model
|
13
|
-
# method.
|
14
|
+
# The {#initialize} method is used to create a new UTM coordinate. You will
|
15
|
+
# often create UTM objects by calling the method {Sketchup::Model#point_to_utm}
|
16
|
+
# instead of calling this method.
|
14
17
|
#
|
15
18
|
# @example
|
16
19
|
# # Create a copy of an existing UTM object.
|
17
|
-
# utm = Geom::UTM.new
|
20
|
+
# utm = Geom::UTM.new(utm2)
|
18
21
|
#
|
19
22
|
# # Create a new UTM object from scratch.
|
20
|
-
# utm = Geom::UTM.new
|
23
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
24
|
+
#
|
25
|
+
# @overload initialize(zone_number, zone_letter, x, y)
|
26
|
+
#
|
27
|
+
# @param [Integer] zone_number A zone number or a UTM object.
|
28
|
+
# @param [String] zone_letter A zone letter.
|
29
|
+
# @param [Float] x The x position.
|
30
|
+
# @param [Float] y The y position.
|
21
31
|
#
|
22
|
-
# @
|
23
|
-
# A zone number or a UTM object. If this first parameter
|
24
|
-
# is a UTM object, then the other parameters are ignored.
|
32
|
+
# @overload initialize(utm)
|
25
33
|
#
|
26
|
-
#
|
27
|
-
# A zone letter.
|
34
|
+
# @param [Geom::UTM] utm A UTM object.
|
28
35
|
#
|
29
|
-
# @
|
30
|
-
# The y position.
|
36
|
+
# @overload initialize(array)
|
31
37
|
#
|
32
|
-
#
|
33
|
-
#
|
38
|
+
# @param [Array(Integer, String, Float, Float)] An array containing the zone
|
39
|
+
# number, zone letter, x and y positions.
|
34
40
|
#
|
35
|
-
# @return
|
41
|
+
# @return [Geom::UTM]
|
36
42
|
#
|
37
43
|
# @version SketchUp 6.0
|
38
|
-
def initialize(
|
44
|
+
def initialize(*args)
|
39
45
|
end
|
40
46
|
|
41
|
-
# The to_a method returns a UTM coordinate as a 4 element array. The Array
|
47
|
+
# The {#to_a} method returns a UTM coordinate as a 4 element array. The Array
|
42
48
|
# elements are the zone number, the zone letter, the x coordinate and the y
|
43
49
|
# coordinate.
|
44
50
|
#
|
45
51
|
# @example
|
46
52
|
# # Create a new UTM object from scratch.
|
47
|
-
# utm = Geom::UTM.new
|
53
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
48
54
|
# a = utm.to_a
|
49
55
|
#
|
50
|
-
# @return
|
56
|
+
# @return [Array(Integer, String, Float, Float)]
|
51
57
|
#
|
52
58
|
# @version SketchUp 6.0
|
53
59
|
def to_a
|
54
60
|
end
|
55
61
|
|
56
|
-
# The to_latlong method is used to convert UTM coordinates to latitude
|
62
|
+
# The {#to_latlong} method is used to convert UTM coordinates to latitude
|
57
63
|
# and longitude. See the LatLong class for more information.
|
58
64
|
#
|
59
65
|
# @example
|
60
66
|
# # Create a new UTM object from scratch.
|
61
|
-
# utm = Geom::UTM.new
|
67
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
62
68
|
# ll = utm.to_latlong
|
63
69
|
#
|
64
|
-
# @return
|
70
|
+
# @return [Geom::LatLong]
|
65
71
|
#
|
66
72
|
# @version SketchUp 6.0
|
67
73
|
def to_latlong
|
68
74
|
end
|
69
75
|
|
70
|
-
# The to_s method is used to retrieve a string representation of a UTM.
|
76
|
+
# The {#to_s} method is used to retrieve a string representation of a UTM.
|
71
77
|
#
|
72
78
|
# @example
|
73
79
|
# # Create a new UTM object from scratch.
|
74
|
-
# utm = Geom::UTM.new
|
80
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
75
81
|
# string = utm.to_s
|
76
82
|
#
|
77
|
-
# @return
|
83
|
+
# @return [String]
|
78
84
|
#
|
79
85
|
# @version SketchUp 6.0
|
80
86
|
def to_s
|
81
87
|
end
|
82
88
|
|
83
|
-
# The x method returns the UTM x coordinate.
|
89
|
+
# The {#x} method returns the UTM x coordinate.
|
84
90
|
#
|
85
91
|
# @example
|
86
92
|
# # Create a new UTM object from scratch.
|
87
|
-
# utm = Geom::UTM.new
|
93
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
88
94
|
# x = utm.x
|
89
95
|
#
|
90
|
-
# @return
|
96
|
+
# @return [Float]
|
91
97
|
#
|
92
98
|
# @version SketchUp 6.0
|
93
99
|
def x
|
94
100
|
end
|
95
101
|
|
96
|
-
# The
|
102
|
+
# The {#y} method returns the UTM y coordinate.
|
97
103
|
#
|
98
104
|
# @example
|
99
105
|
# # Create a new UTM object from scratch.
|
100
|
-
# utm = Geom::UTM.new
|
106
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
101
107
|
# y = utm.y
|
102
108
|
#
|
103
|
-
# @return
|
109
|
+
# @return [Float]
|
104
110
|
#
|
105
111
|
# @version SketchUp 6.0
|
106
112
|
def y
|
107
113
|
end
|
108
114
|
|
109
|
-
# The zone_letter method returns the UTM zone letter.
|
115
|
+
# The {#zone_letter} method returns the UTM zone letter.
|
110
116
|
#
|
111
117
|
# @example
|
112
118
|
# # Create a new UTM object from scratch.
|
113
|
-
# utm = Geom::UTM.new
|
119
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
114
120
|
# zl = utm.zone_letter
|
115
121
|
#
|
116
|
-
# @return
|
122
|
+
# @return [String]
|
117
123
|
#
|
118
124
|
# @version SketchUp 6.0
|
119
125
|
def zone_letter
|
120
126
|
end
|
121
127
|
|
122
|
-
# The zone_number method returns the UTM zone number.
|
128
|
+
# The {#zone_number} method returns the UTM zone number.
|
123
129
|
#
|
124
130
|
# @example
|
125
131
|
# # Create a new UTM object from scratch.
|
126
|
-
# utm = Geom::UTM.new
|
132
|
+
# utm = Geom::UTM.new(13, "T", 475849.37521, 4429682.73749)
|
127
133
|
# zn = utm.zone_number
|
128
134
|
#
|
129
|
-
# @return
|
135
|
+
# @return [Integer]
|
130
136
|
#
|
131
137
|
# @version SketchUp 6.0
|
132
138
|
def zone_number
|
@@ -0,0 +1,497 @@
|
|
1
|
+
# Copyright:: Copyright 2017 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# The Vector2d class represents vectors in a 2 dimensional space.
|
5
|
+
# Vectors in LayOut have a direction and a length, but not a starting point.
|
6
|
+
#
|
7
|
+
# There are numerous tutorials on 2D vectors available on the internet.
|
8
|
+
#
|
9
|
+
# @version LayOut 2018
|
10
|
+
class Geom::Vector2d
|
11
|
+
|
12
|
+
# Instance Methods
|
13
|
+
|
14
|
+
# The {#%} method returns the dot product between two {Geom::Vector2d}. This is
|
15
|
+
# an alias of the dot method.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# vector = Geom::Vector2d.new(0, 2)
|
19
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
20
|
+
# d2 = vector % vector2
|
21
|
+
#
|
22
|
+
# @param [Geom::Vector2d] vector
|
23
|
+
#
|
24
|
+
# @return The dot product of the vectors
|
25
|
+
#
|
26
|
+
# @version LayOut 2018
|
27
|
+
def %(vector)
|
28
|
+
end
|
29
|
+
|
30
|
+
# The {#*} method returns the cross product between two {Geom::Vector2d}. This
|
31
|
+
# is an alias of the cross method.
|
32
|
+
#
|
33
|
+
# @example
|
34
|
+
# vector = Geom::Vector2d.new(1, 0)
|
35
|
+
# vector2 = Geom::Vector2d.new(0, 1)
|
36
|
+
# cross = vector * vector
|
37
|
+
#
|
38
|
+
# @param [Geom::Vector2d] vector
|
39
|
+
#
|
40
|
+
# @return [Geom::Vector2d]
|
41
|
+
#
|
42
|
+
# @version LayOut 2018
|
43
|
+
def *(vector)
|
44
|
+
end
|
45
|
+
|
46
|
+
# The {#+} method adds a {Geom::Vector2d} to this one.
|
47
|
+
#
|
48
|
+
# @example
|
49
|
+
# vector = Geom::Vector2d.new(0, 2)
|
50
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
51
|
+
# new_vector = vector + vector2
|
52
|
+
#
|
53
|
+
# @param [Geom::Vector2d] vector
|
54
|
+
#
|
55
|
+
# @return [Geom::Vector2d]
|
56
|
+
#
|
57
|
+
# @version LayOut 2018
|
58
|
+
def +(vector)
|
59
|
+
end
|
60
|
+
|
61
|
+
# The {#-} method subtracts a {Geom::Vector2d} from this one.
|
62
|
+
#
|
63
|
+
# @example
|
64
|
+
# vector = Geom::Vector2d.new(0, 2)
|
65
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
66
|
+
# new_vector = vector - vector2
|
67
|
+
#
|
68
|
+
# @param [Geom::Vector2d] vector
|
69
|
+
#
|
70
|
+
# @return [Geom::Vector2d]
|
71
|
+
#
|
72
|
+
# @version LayOut 2018
|
73
|
+
def -(vector)
|
74
|
+
end
|
75
|
+
|
76
|
+
# The {#==} method returns whether two {Geom::Vector2d} are equal within
|
77
|
+
# tolerance.
|
78
|
+
#
|
79
|
+
# @example
|
80
|
+
# vector = Geom::Vector2d.new(1, 0)
|
81
|
+
# vector2 = Geom::Vector2d.new(0,1)
|
82
|
+
# # Returns false
|
83
|
+
# status = vector == vector2
|
84
|
+
#
|
85
|
+
# @param [Geom::Vector2d] vector
|
86
|
+
#
|
87
|
+
# @return [Boolean]
|
88
|
+
#
|
89
|
+
# @version LayOut 2018
|
90
|
+
def ==(vector)
|
91
|
+
end
|
92
|
+
|
93
|
+
# The {#[]} method returns the value of the {Geom::Vector2d} at the specified
|
94
|
+
# index.
|
95
|
+
#
|
96
|
+
# @example
|
97
|
+
# vector = Geom::Vector2d.new(1, 2)
|
98
|
+
# # retrieves the y value of 2
|
99
|
+
# yvalue = vector[1]
|
100
|
+
#
|
101
|
+
# @param [Numeric] index
|
102
|
+
# The index into an array of two coordinates.
|
103
|
+
#
|
104
|
+
# @return [Numeric] The value for the x or y coordinate.
|
105
|
+
#
|
106
|
+
# @version LayOut 2018
|
107
|
+
def [](index)
|
108
|
+
end
|
109
|
+
|
110
|
+
# The {#[]=} method sets the x or y value of the {Geom::Vector2d} based on the
|
111
|
+
# specific index of the value.
|
112
|
+
#
|
113
|
+
# @example
|
114
|
+
# point = Geom::Vector2d.new(1,2)
|
115
|
+
# point[1] = 4
|
116
|
+
#
|
117
|
+
# @param [Numeric] index
|
118
|
+
# The index for a specific x or y value in the
|
119
|
+
# {Geom::Vector2d} to set
|
120
|
+
#
|
121
|
+
# @param [Numeric] value
|
122
|
+
# The value to set for x or y
|
123
|
+
#
|
124
|
+
# @return [Numeric] The new x or y value if successful
|
125
|
+
#
|
126
|
+
# @version LayOut 2018
|
127
|
+
def []=(index, value)
|
128
|
+
end
|
129
|
+
|
130
|
+
# The {#angle_between} method computes the angle in radians between
|
131
|
+
# the {Geom::Vector2d} and another {Geom::Vector2d}.
|
132
|
+
#
|
133
|
+
# @example
|
134
|
+
# vector = Geom::Vector2d.new(1, 0)
|
135
|
+
# vector2 = Geom::Vector2d.new(-1, 0)
|
136
|
+
# # returns PI
|
137
|
+
# angle = vector.angle_between(vector2)
|
138
|
+
#
|
139
|
+
# @param [Geom::Vector2d] vector
|
140
|
+
#
|
141
|
+
# @return [Numeric] The angle (in radians)
|
142
|
+
#
|
143
|
+
# @version LayOut 2018
|
144
|
+
def angle_between(vector)
|
145
|
+
end
|
146
|
+
|
147
|
+
# The {#clone} method makes a copy of the {Geom::Vector2d}. This method is
|
148
|
+
# equivalent to vec2 = Geom::Vector2d.new(vec).
|
149
|
+
#
|
150
|
+
# @example
|
151
|
+
# vector = Geom::Vector2d.new(1, 0)
|
152
|
+
# vector2 = vector.clone
|
153
|
+
#
|
154
|
+
# @return [Geom::Vector2d]
|
155
|
+
#
|
156
|
+
# @version LayOut 2018
|
157
|
+
def clone
|
158
|
+
end
|
159
|
+
|
160
|
+
# The {#*} method returns the cross product between two {Geom::Vector2d}. This
|
161
|
+
# is an alias of the cross method.
|
162
|
+
#
|
163
|
+
# @example
|
164
|
+
# vector = Geom::Vector2d.new(1, 0)
|
165
|
+
# vector2 = Geom::Vector2d.new(0, 1)
|
166
|
+
# cross = vector * vector
|
167
|
+
#
|
168
|
+
# @param [Geom::Vector2d] vector
|
169
|
+
#
|
170
|
+
# @return [Geom::Vector2d]
|
171
|
+
#
|
172
|
+
# @version LayOut 2018
|
173
|
+
def cross(vector)
|
174
|
+
end
|
175
|
+
|
176
|
+
# The {#%} method returns the dot product between two {Geom::Vector2d}. This is
|
177
|
+
# an alias of the dot method.
|
178
|
+
#
|
179
|
+
# @example
|
180
|
+
# vector = Geom::Vector2d.new(0, 2)
|
181
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
182
|
+
# d2 = vector % vector2
|
183
|
+
#
|
184
|
+
# @param [Geom::Vector2d] vector
|
185
|
+
#
|
186
|
+
# @return The dot product of the vectors
|
187
|
+
#
|
188
|
+
# @version LayOut 2018
|
189
|
+
def dot(vector)
|
190
|
+
end
|
191
|
+
|
192
|
+
# The {.new} method creates a new {Geom::Vector2d}.
|
193
|
+
#
|
194
|
+
# @example
|
195
|
+
# # A vector that runs along the X axis.
|
196
|
+
# vector = Geom::Vector2d.new(1, 0)
|
197
|
+
#
|
198
|
+
# @overload initialize
|
199
|
+
#
|
200
|
+
# @return [Geom::Vector2d]
|
201
|
+
#
|
202
|
+
# @overload initialize(vector)
|
203
|
+
#
|
204
|
+
# @param [Geom::Vector2d, Array(Numeric, Numeric)] vector
|
205
|
+
# @return [Geom::Vector2d]
|
206
|
+
#
|
207
|
+
# @overload initialize(x, y)
|
208
|
+
#
|
209
|
+
# @param [Numeric] x The length in the x direction
|
210
|
+
# @param [Numeric] y The length in the y direction
|
211
|
+
# @return [Geom::Vector2d]
|
212
|
+
#
|
213
|
+
# @version LayOut 2018
|
214
|
+
def initialize(*args)
|
215
|
+
end
|
216
|
+
|
217
|
+
# The {#inspect} method formats the {Geom::Vector2d} as a string.
|
218
|
+
#
|
219
|
+
# @example
|
220
|
+
# point = Geom::Point2d.new(1, 2)
|
221
|
+
# string = point.inspect
|
222
|
+
#
|
223
|
+
# @return [String] the string representation of the {Geom::Vector2d}
|
224
|
+
#
|
225
|
+
# @version LayOut 2018
|
226
|
+
def inspect
|
227
|
+
end
|
228
|
+
|
229
|
+
# The {#length} method returns the length of the {Geom::Vector2d}.
|
230
|
+
#
|
231
|
+
# @example
|
232
|
+
# vector = Geom::Vector2d.new(0, 4)
|
233
|
+
# # returns 4
|
234
|
+
# l = vector.length
|
235
|
+
#
|
236
|
+
# @return [Numeric] The length of the {Geom::Vector2d}
|
237
|
+
#
|
238
|
+
# @version LayOut 2018
|
239
|
+
def length
|
240
|
+
end
|
241
|
+
|
242
|
+
# The {#length=} method sets the length of the {Geom::Vector2d}. The new length
|
243
|
+
# must be greater than 0.
|
244
|
+
#
|
245
|
+
# @example
|
246
|
+
# vector = Geom::Vector2d.new(0, 4)
|
247
|
+
# l = vector.length
|
248
|
+
# vector.length = 2
|
249
|
+
#
|
250
|
+
# @param [Numeric] length
|
251
|
+
# The new length for the {Geom::Vector2d}
|
252
|
+
#
|
253
|
+
# @return [Numeric] The new length
|
254
|
+
#
|
255
|
+
# @version LayOut 2018
|
256
|
+
def length=(length)
|
257
|
+
end
|
258
|
+
|
259
|
+
# The {#normalize} method returns a {Geom::Vector2d} that is a unit vector
|
260
|
+
# of the {Geom::Vector2d}.
|
261
|
+
#
|
262
|
+
# @example
|
263
|
+
# vector = Geom::Vector2d.new(0, 4)
|
264
|
+
# # returns a new Vector2d(0, 1)
|
265
|
+
# vector2 = vector.normalize
|
266
|
+
#
|
267
|
+
# @return [Geom::Vector2d]
|
268
|
+
#
|
269
|
+
# @version LayOut 2018
|
270
|
+
def normalize
|
271
|
+
end
|
272
|
+
|
273
|
+
# The {#normalize!} method converts a {Geom::Vector2d} vector into a unit
|
274
|
+
# vector. Another way to do this is vector.length = 1
|
275
|
+
#
|
276
|
+
# @example
|
277
|
+
# vector = Geom::Vector2d.new(0, 4)
|
278
|
+
# # modifies vector to be the Vector2d(0, 1)
|
279
|
+
# vector.normalize!
|
280
|
+
#
|
281
|
+
# @version LayOut 2018
|
282
|
+
def normalize!
|
283
|
+
end
|
284
|
+
|
285
|
+
# The {#parallel?} method determines if the {Geom::Vector2d} is parallel to
|
286
|
+
# another {Geom::Vector2d} to within tolerance.
|
287
|
+
#
|
288
|
+
# @example
|
289
|
+
# vector = Geom::Vector2d.new(0, 1)
|
290
|
+
# vector2 = Geom::Vector2d.new(1, 2)
|
291
|
+
# # returns true
|
292
|
+
# status = vector.parallel?(vector2)
|
293
|
+
#
|
294
|
+
# @param [Geom::Vector2d] vector
|
295
|
+
#
|
296
|
+
# @return [Boolean]
|
297
|
+
#
|
298
|
+
# @return [Boolean]
|
299
|
+
#
|
300
|
+
# @version LayOut 2018
|
301
|
+
def parallel?(vector)
|
302
|
+
end
|
303
|
+
|
304
|
+
# The {#perpendicular?} method determines if the {Geom::Vector2d} is
|
305
|
+
# perpendicular to another {Geom::Vector2d} to within tolerance.
|
306
|
+
#
|
307
|
+
# @example
|
308
|
+
# vector = Geom::Vector2d.new(0, 1)
|
309
|
+
# vector2 = Geom::Vector2d.new(1, 2)
|
310
|
+
# # returns false
|
311
|
+
# status = vector.perpendicular?(vector2)
|
312
|
+
#
|
313
|
+
# @param [Geom::Vector2d] vector
|
314
|
+
#
|
315
|
+
# @return [Boolean]
|
316
|
+
#
|
317
|
+
# @return [Boolean]
|
318
|
+
#
|
319
|
+
# @version LayOut 2018
|
320
|
+
def perpendicular?(vector)
|
321
|
+
end
|
322
|
+
|
323
|
+
# The {#reverse} method returns a new {Geom::Vector2d} that is the reverse of
|
324
|
+
# the {Geom::Vector2d}, leaving the original unchanged.
|
325
|
+
#
|
326
|
+
# @example
|
327
|
+
# vector = Geom::Vector2d.new(1, 2)
|
328
|
+
# # returns the Vector2d(-1, -2)
|
329
|
+
# vector2 = vector.reverse
|
330
|
+
#
|
331
|
+
# @return [Geom::Vector2d]
|
332
|
+
#
|
333
|
+
# @version LayOut 2018
|
334
|
+
def reverse
|
335
|
+
end
|
336
|
+
|
337
|
+
# The {#reverse!} method reverses the {Geom::Vector2d} in place.
|
338
|
+
#
|
339
|
+
# @example
|
340
|
+
# vector = Geom::Vector2d.new(1, 2)
|
341
|
+
# # modifies vector to be the Vector2d(-1, -2)
|
342
|
+
# vector.reverse!
|
343
|
+
#
|
344
|
+
# @version LayOut 2018
|
345
|
+
def reverse!
|
346
|
+
end
|
347
|
+
|
348
|
+
# The {#same_direction?} method determines if the {Geom::Vector2d} is parallel
|
349
|
+
# to and in the same direction as another {Geom::Vector2d} within tolerance.
|
350
|
+
#
|
351
|
+
# @example
|
352
|
+
# vector = Geom::Vector2d.new(0, 1)
|
353
|
+
# vector2 = Geom::Vector2d.new(1, 2)
|
354
|
+
# # returns true
|
355
|
+
# status = vector.sime_direction?(vector2)
|
356
|
+
#
|
357
|
+
# @param [Geom::Vector2d] vector
|
358
|
+
#
|
359
|
+
# @return [Boolean]
|
360
|
+
#
|
361
|
+
# @return [Boolean]
|
362
|
+
#
|
363
|
+
# @version LayOut 2018
|
364
|
+
def same_direction?(vector)
|
365
|
+
end
|
366
|
+
|
367
|
+
# The {#set!} method sets the values of the {Geom::Vector2d}.
|
368
|
+
#
|
369
|
+
# @example
|
370
|
+
# vector = Geom::Vector2d.new(1, 2)
|
371
|
+
# vector = vector.set!([4, 5])
|
372
|
+
#
|
373
|
+
# @overload set!(vector)
|
374
|
+
#
|
375
|
+
# @param [Geom::Vector2d, Array(Numeric, Numeric)] vector
|
376
|
+
# @return [Geom::Vector2d]
|
377
|
+
#
|
378
|
+
# @overload set!(x, y)
|
379
|
+
#
|
380
|
+
# @param [Numeric] x
|
381
|
+
# @param [Numeric] y
|
382
|
+
# @return [Geom::Vector2d]
|
383
|
+
#
|
384
|
+
# @version LayOut 2018
|
385
|
+
def set!(*args)
|
386
|
+
end
|
387
|
+
|
388
|
+
# The {#to_a} method retrieves the coordinates of the {Geom::Vector2d} in an
|
389
|
+
# Array.
|
390
|
+
#
|
391
|
+
# @example
|
392
|
+
# a = vector.to_a
|
393
|
+
#
|
394
|
+
# @return [Array(Numeric, Numeric)]
|
395
|
+
#
|
396
|
+
# @version LayOut 2018
|
397
|
+
def to_a
|
398
|
+
end
|
399
|
+
|
400
|
+
# The {#to_s} method returns a string representation of the {Geom::Vector2d}.
|
401
|
+
#
|
402
|
+
# @example
|
403
|
+
# point = Geom::Vector2d.new(1, 2)
|
404
|
+
# str = point.to_s
|
405
|
+
#
|
406
|
+
# @return [String] the string representation of the {Geom::Vector2d}
|
407
|
+
#
|
408
|
+
# @version LayOut 2018
|
409
|
+
def to_s
|
410
|
+
end
|
411
|
+
|
412
|
+
# The {#unit_vector?} method returns whether the {Geom::Vector2d} is a unit
|
413
|
+
# vector. This is equivalent to vector.length == 1.0
|
414
|
+
#
|
415
|
+
# @example
|
416
|
+
# vector = Geom::Vector2d.new(1, 0)
|
417
|
+
# # returns true
|
418
|
+
# status = vector.unit_vector
|
419
|
+
#
|
420
|
+
# @return [Boolean]
|
421
|
+
#
|
422
|
+
# @return [Boolean]
|
423
|
+
#
|
424
|
+
# @version LayOut 2018
|
425
|
+
def unit_vector?
|
426
|
+
end
|
427
|
+
|
428
|
+
# The {#valid?} method verifies if a {Geom::Vector2d} is valid. A
|
429
|
+
# {Geom::Vector2d} is valid if its length is not zero.
|
430
|
+
#
|
431
|
+
# @example
|
432
|
+
# vector = Geom::Vector2d.new(0, 4)
|
433
|
+
# status = vector.valid
|
434
|
+
#
|
435
|
+
# @return [Boolean]
|
436
|
+
#
|
437
|
+
# @return [Boolean]
|
438
|
+
#
|
439
|
+
# @version LayOut 2018
|
440
|
+
def valid?
|
441
|
+
end
|
442
|
+
|
443
|
+
# The {#x} method retrieves the x value of the {Geom::Vector2d}.
|
444
|
+
#
|
445
|
+
# @example
|
446
|
+
# vector = Geom::Vector2d.new(1, 2)
|
447
|
+
# x = vector.x
|
448
|
+
#
|
449
|
+
# @return [Numeric]
|
450
|
+
#
|
451
|
+
# @version LayOut 2018
|
452
|
+
def x
|
453
|
+
end
|
454
|
+
|
455
|
+
# The {#x=} method sets the x coordinate of the {Geom::Vector2d}.
|
456
|
+
#
|
457
|
+
# @example
|
458
|
+
# vector = Geom::Vector2d.new(1, 2)
|
459
|
+
# vector.x = 7
|
460
|
+
#
|
461
|
+
# @param [Numeric] x
|
462
|
+
# The desired x value of the {Geom::Vector2d}
|
463
|
+
#
|
464
|
+
# @return [Numeric] The new x value of the {Geom::Vector2d}
|
465
|
+
#
|
466
|
+
# @version LayOut 2018
|
467
|
+
def x=(x)
|
468
|
+
end
|
469
|
+
|
470
|
+
# The {#y} method retrieves the y value of the {Geom::Vector2d}.
|
471
|
+
#
|
472
|
+
# @example
|
473
|
+
# vector = Geom::Vector2d.new(1, 2)
|
474
|
+
# y = vector.y
|
475
|
+
#
|
476
|
+
# @return [Numeric]
|
477
|
+
#
|
478
|
+
# @version LayOut 2018
|
479
|
+
def y
|
480
|
+
end
|
481
|
+
|
482
|
+
# The {#y=} method sets the y coordinate of the {Geom::Vector2d}.
|
483
|
+
#
|
484
|
+
# @example
|
485
|
+
# vector = Geom::Vector2d.new(1, 2)
|
486
|
+
# vector.y = 7
|
487
|
+
#
|
488
|
+
# @param [Numeric] y
|
489
|
+
# The desired y value of the {Geom::Vector2d}
|
490
|
+
#
|
491
|
+
# @return [Numeric] The new y value of the {Geom::Vector2d}
|
492
|
+
#
|
493
|
+
# @version LayOut 2018
|
494
|
+
def y=(y)
|
495
|
+
end
|
496
|
+
|
497
|
+
end
|