sketchup-api-stubs 0.7.7 → 0.7.9
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/lib/sketchup-api-stubs/sketchup.rb +151 -147
- data/lib/sketchup-api-stubs/stubs/{array.rb → Array.rb} +741 -741
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +322 -322
- data/lib/sketchup-api-stubs/stubs/Geom/Bounds2d.rb +172 -172
- data/lib/sketchup-api-stubs/stubs/Geom/LatLong.rb +126 -126
- data/lib/sketchup-api-stubs/stubs/Geom/OrientedBounds2d.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Geom/Point2d.rb +400 -400
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +661 -661
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +509 -509
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +476 -478
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation2d.rb +263 -263
- data/lib/sketchup-api-stubs/stubs/Geom/UTM.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Geom/Vector2d.rb +522 -522
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +693 -691
- data/lib/sketchup-api-stubs/stubs/{geom.rb → Geom.rb} +351 -351
- data/lib/sketchup-api-stubs/stubs/{languagehandler.rb → LanguageHandler.rb} +93 -92
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +595 -573
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +747 -411
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +183 -179
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +517 -515
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +148 -148
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +354 -349
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -91
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +370 -370
- data/lib/sketchup-api-stubs/stubs/Layout/Layer.rb +218 -218
- data/lib/sketchup-api-stubs/stubs/Layout/LayerInstance.rb +128 -128
- data/lib/sketchup-api-stubs/stubs/Layout/Layers.rb +225 -225
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +567 -567
- data/lib/sketchup-api-stubs/stubs/Layout/LockedEntityError.rb +10 -10
- data/lib/sketchup-api-stubs/stubs/Layout/LockedLayerError.rb +11 -11
- data/lib/sketchup-api-stubs/stubs/Layout/Page.rb +183 -183
- data/lib/sketchup-api-stubs/stubs/Layout/PageInfo.rb +387 -387
- data/lib/sketchup-api-stubs/stubs/Layout/Pages.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Layout/Path.rb +344 -344
- data/lib/sketchup-api-stubs/stubs/Layout/Rectangle.rb +174 -174
- data/lib/sketchup-api-stubs/stubs/Layout/ReferenceEntity.rb +82 -0
- data/lib/sketchup-api-stubs/stubs/Layout/SketchUpModel.rb +692 -694
- data/lib/sketchup-api-stubs/stubs/Layout/Style.rb +1519 -1519
- data/lib/sketchup-api-stubs/stubs/Layout/Table.rb +290 -290
- data/lib/sketchup-api-stubs/stubs/Layout/TableCell.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Layout/TableColumn.rb +139 -139
- data/lib/sketchup-api-stubs/stubs/Layout/TableRow.rb +135 -135
- data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
- data/lib/sketchup-api-stubs/stubs/{length.rb → Length.rb} +278 -278
- data/lib/sketchup-api-stubs/stubs/{numeric.rb → Numeric.rb} +249 -249
- data/lib/sketchup-api-stubs/stubs/Sketchup/Animation.rb +144 -144
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +169 -157
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +150 -152
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +281 -286
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +302 -302
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +121 -122
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +294 -294
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +659 -577
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +593 -594
- data/lib/sketchup-api-stubs/stubs/Sketchup/Console.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionLine.rb +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ConstructionPoint.rb +32 -32
- data/lib/sketchup-api-stubs/stubs/Sketchup/Curve.rb +201 -201
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +449 -425
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +74 -74
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +104 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +306 -306
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +42 -42
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +406 -396
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +397 -502
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1239 -1126
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesBuilder.rb +261 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +127 -127
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +545 -545
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +60 -60
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +125 -126
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +937 -917
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +102 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +750 -750
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +282 -292
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +468 -468
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +266 -266
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +189 -189
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +406 -405
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +84 -84
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +306 -306
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +326 -327
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayerFolder.rb +422 -422
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +427 -427
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +249 -249
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +114 -112
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +414 -414
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +317 -318
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +93 -93
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1652 -1654
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +357 -357
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +130 -131
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +271 -284
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/Overlay.rb +490 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/OverlaysManager.rb +116 -0
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +797 -797
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +361 -363
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +77 -77
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +478 -478
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +361 -364
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +45 -45
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +458 -459
- data/lib/sketchup-api-stubs/stubs/Sketchup/SelectionObserver.rb +115 -115
- data/lib/sketchup-api-stubs/stubs/Sketchup/Set.rb +212 -212
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfo.rb +255 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +59 -59
- data/lib/sketchup-api-stubs/stubs/Sketchup/Skp.rb +40 -40
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +217 -217
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +217 -217
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +834 -835
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +156 -156
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +75 -71
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1311 -1307
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +45 -45
- data/lib/sketchup-api-stubs/stubs/{sketchup.rb → Sketchup.rb} +1377 -1353
- data/lib/sketchup-api-stubs/stubs/{sketchupextension.rb → SketchupExtension.rb} +353 -353
- data/lib/sketchup-api-stubs/stubs/{string.rb → String.rb} +24 -24
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +389 -317
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +494 -478
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +269 -269
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +241 -240
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +635 -633
- data/lib/sketchup-api-stubs/stubs/{ui.rb → UI.rb} +683 -672
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +303 -311
- data/lib/sketchup-api-stubs.rb +1 -1
- metadata +20 -16
@@ -1,522 +1,522 @@
|
|
1
|
-
# Copyright:: Copyright
|
2
|
-
# License:: The MIT License (MIT)
|
3
|
-
|
4
|
-
# The {Geom::Vector2d} class represents vectors in a 2 dimensional space.
|
5
|
-
#
|
6
|
-
# There are numerous tutorials on 2D vectors available on the internet.
|
7
|
-
#
|
8
|
-
# @version LayOut 2018
|
9
|
-
class Geom::Vector2d
|
10
|
-
|
11
|
-
# Instance Methods
|
12
|
-
|
13
|
-
# The {#%} method returns the dot product between two {Geom::Vector2d}. This is
|
14
|
-
# an alias of the dot method.
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# vector = Geom::Vector2d.new(0, 2)
|
18
|
-
# vector2 = Geom::Vector2d.new(1, 0)
|
19
|
-
# d2 = vector % vector2
|
20
|
-
#
|
21
|
-
# @param [Geom::Vector2d] vector
|
22
|
-
#
|
23
|
-
# @return The dot product of the vectors
|
24
|
-
#
|
25
|
-
# @version LayOut 2018
|
26
|
-
def %(vector)
|
27
|
-
end
|
28
|
-
|
29
|
-
# The {#*} method returns the cross product between two {Geom::Vector2d}. This
|
30
|
-
# is an alias of the cross method.
|
31
|
-
#
|
32
|
-
# @example
|
33
|
-
# vector = Geom::Vector2d.new(1, 0)
|
34
|
-
# vector2 = Geom::Vector2d.new(0, 1)
|
35
|
-
# cross = vector * vector
|
36
|
-
#
|
37
|
-
# @param [Geom::Vector2d] vector
|
38
|
-
#
|
39
|
-
# @return [Geom::Vector2d]
|
40
|
-
#
|
41
|
-
# @version LayOut 2018
|
42
|
-
def *(vector)
|
43
|
-
end
|
44
|
-
|
45
|
-
# The {#+} method adds a {Geom::Vector2d} to this one.
|
46
|
-
#
|
47
|
-
# @example
|
48
|
-
# vector = Geom::Vector2d.new(0, 2)
|
49
|
-
# vector2 = Geom::Vector2d.new(1, 0)
|
50
|
-
# new_vector = vector + vector2
|
51
|
-
#
|
52
|
-
# @param [Geom::Vector2d] vector
|
53
|
-
#
|
54
|
-
# @return [Geom::Vector2d]
|
55
|
-
#
|
56
|
-
# @version LayOut 2018
|
57
|
-
def +(vector)
|
58
|
-
end
|
59
|
-
|
60
|
-
# The {#-} method subtracts a {Geom::Vector2d} from this one.
|
61
|
-
#
|
62
|
-
# @example
|
63
|
-
# vector = Geom::Vector2d.new(0, 2)
|
64
|
-
# vector2 = Geom::Vector2d.new(1, 0)
|
65
|
-
# new_vector = vector - vector2
|
66
|
-
#
|
67
|
-
# @param [Geom::Vector2d] vector
|
68
|
-
#
|
69
|
-
# @return [Geom::Vector2d]
|
70
|
-
#
|
71
|
-
# @version LayOut 2018
|
72
|
-
def -(vector)
|
73
|
-
end
|
74
|
-
|
75
|
-
# The {#==} method returns whether two {Geom::Vector2d} are equal within
|
76
|
-
# tolerance.
|
77
|
-
#
|
78
|
-
# @example
|
79
|
-
# vector = Geom::Vector2d.new(1, 0)
|
80
|
-
# vector2 = Geom::Vector2d.new(0,1)
|
81
|
-
# # Returns false
|
82
|
-
# status = vector == vector2
|
83
|
-
#
|
84
|
-
# @param [Geom::Vector2d] vector
|
85
|
-
#
|
86
|
-
# @return [Boolean]
|
87
|
-
#
|
88
|
-
# @version LayOut 2018
|
89
|
-
def ==(vector)
|
90
|
-
end
|
91
|
-
|
92
|
-
# The {#[]} method returns the value of the {Geom::Vector2d} at the specified
|
93
|
-
# index.
|
94
|
-
#
|
95
|
-
# @example
|
96
|
-
# vector = Geom::Vector2d.new(1, 2)
|
97
|
-
# # retrieves the y value of 2
|
98
|
-
# yvalue = vector[1]
|
99
|
-
#
|
100
|
-
# @param [Integer] index
|
101
|
-
# The index into an array of two coordinates.
|
102
|
-
#
|
103
|
-
# @return [Numeric] The value for the x or y coordinate.
|
104
|
-
#
|
105
|
-
# @version LayOut 2018
|
106
|
-
def [](index)
|
107
|
-
end
|
108
|
-
|
109
|
-
# The {#[]=} method sets the x or y value of the {Geom::Vector2d} based on the
|
110
|
-
# specific index of the value.
|
111
|
-
#
|
112
|
-
# @example
|
113
|
-
# point = Geom::Vector2d.new(1,2)
|
114
|
-
# point[1] = 4
|
115
|
-
#
|
116
|
-
# @param [Numeric] index
|
117
|
-
# The index for a specific x or y value in the
|
118
|
-
# {Geom::Vector2d} to set
|
119
|
-
#
|
120
|
-
# @param [Numeric] value
|
121
|
-
# The value to set for x or y
|
122
|
-
#
|
123
|
-
# @return [Numeric] The new x or y value if successful
|
124
|
-
#
|
125
|
-
# @version LayOut 2018
|
126
|
-
def []=(index, value)
|
127
|
-
end
|
128
|
-
|
129
|
-
# The {#angle_between} method computes the angle in radians between
|
130
|
-
# the {Geom::Vector2d} and another {Geom::Vector2d}.
|
131
|
-
#
|
132
|
-
# @example
|
133
|
-
# vector = Geom::Vector2d.new(1, 0)
|
134
|
-
# vector2 = Geom::Vector2d.new(-1, 0)
|
135
|
-
# # returns PI
|
136
|
-
# angle = vector.angle_between(vector2)
|
137
|
-
#
|
138
|
-
# @param [Geom::Vector2d] vector
|
139
|
-
#
|
140
|
-
# @return [Numeric] The angle (in radians)
|
141
|
-
#
|
142
|
-
# @version LayOut 2018
|
143
|
-
def angle_between(vector)
|
144
|
-
end
|
145
|
-
|
146
|
-
# The {#clone} method makes a copy of the {Geom::Vector2d}. This method is
|
147
|
-
# equivalent to vec2 = Geom::Vector2d.new(vec).
|
148
|
-
#
|
149
|
-
# @example
|
150
|
-
# vector = Geom::Vector2d.new(1, 0)
|
151
|
-
# vector2 = vector.clone
|
152
|
-
#
|
153
|
-
# @return [Geom::Vector2d]
|
154
|
-
#
|
155
|
-
# @version LayOut 2018
|
156
|
-
def clone
|
157
|
-
end
|
158
|
-
|
159
|
-
# The {#*} method returns the cross product between two {Geom::Vector2d}. This
|
160
|
-
# is an alias of the cross method.
|
161
|
-
#
|
162
|
-
# @example
|
163
|
-
# vector = Geom::Vector2d.new(1, 0)
|
164
|
-
# vector2 = Geom::Vector2d.new(0, 1)
|
165
|
-
# cross = vector * vector
|
166
|
-
#
|
167
|
-
# @param [Geom::Vector2d] vector
|
168
|
-
#
|
169
|
-
# @return [Geom::Vector2d]
|
170
|
-
#
|
171
|
-
# @version LayOut 2018
|
172
|
-
def cross(vector)
|
173
|
-
end
|
174
|
-
|
175
|
-
# The {#%} method returns the dot product between two {Geom::Vector2d}. This is
|
176
|
-
# an alias of the dot method.
|
177
|
-
#
|
178
|
-
# @example
|
179
|
-
# vector = Geom::Vector2d.new(0, 2)
|
180
|
-
# vector2 = Geom::Vector2d.new(1, 0)
|
181
|
-
# d2 = vector % vector2
|
182
|
-
#
|
183
|
-
# @param [Geom::Vector2d] vector
|
184
|
-
#
|
185
|
-
# @return The dot product of the vectors
|
186
|
-
#
|
187
|
-
# @version LayOut 2018
|
188
|
-
def dot(vector)
|
189
|
-
end
|
190
|
-
|
191
|
-
# The {.new} method creates a new {Geom::Vector2d}.
|
192
|
-
#
|
193
|
-
# @example
|
194
|
-
# # A vector that runs along the X axis.
|
195
|
-
# vector = Geom::Vector2d.new(1, 0)
|
196
|
-
#
|
197
|
-
# @overload initialize
|
198
|
-
#
|
199
|
-
# @return [Geom::Vector2d]
|
200
|
-
#
|
201
|
-
# @overload initialize(x, y)
|
202
|
-
#
|
203
|
-
# @param [Numeric] x The length in the x direction
|
204
|
-
# @param [Numeric] y The length in the y direction
|
205
|
-
# @return [Geom::Vector2d]
|
206
|
-
#
|
207
|
-
# @overload initialize(vector)
|
208
|
-
#
|
209
|
-
# @param [Geom::Vector2d, Array(Numeric, Numeric)] vector
|
210
|
-
# @return [Geom::Vector2d]
|
211
|
-
#
|
212
|
-
# @version LayOut 2018
|
213
|
-
def initialize(*args)
|
214
|
-
end
|
215
|
-
|
216
|
-
# The {#inspect} method formats the {Geom::Vector2d} as a string.
|
217
|
-
#
|
218
|
-
# @example
|
219
|
-
# point = Geom::Point2d.new(1, 2)
|
220
|
-
# string = point.inspect
|
221
|
-
#
|
222
|
-
# @return [String] the string representation of the {Geom::Vector2d}
|
223
|
-
#
|
224
|
-
# @version LayOut 2018
|
225
|
-
def inspect
|
226
|
-
end
|
227
|
-
|
228
|
-
# The {#length} method returns the length of the {Geom::Vector2d}.
|
229
|
-
#
|
230
|
-
# @example
|
231
|
-
# vector = Geom::Vector2d.new(0, 4)
|
232
|
-
# # returns 4
|
233
|
-
# l = vector.length
|
234
|
-
#
|
235
|
-
# @return [Length] The length of the {Geom::Vector2d}
|
236
|
-
#
|
237
|
-
# @version LayOut 2018
|
238
|
-
def length
|
239
|
-
end
|
240
|
-
|
241
|
-
# The {#length=} method sets the length of the {Geom::Vector2d}. The new length
|
242
|
-
# must not be 0.
|
243
|
-
#
|
244
|
-
# @example
|
245
|
-
# vector = Geom::Vector2d.new(0, 4)
|
246
|
-
# l = vector.length
|
247
|
-
# vector.length = 2
|
248
|
-
#
|
249
|
-
# @param [Numeric] length
|
250
|
-
# The new length for the {Geom::Vector2d}
|
251
|
-
#
|
252
|
-
# @return [Numeric] The new length
|
253
|
-
#
|
254
|
-
# @version LayOut 2018
|
255
|
-
def length=(length)
|
256
|
-
end
|
257
|
-
|
258
|
-
# The {#normalize} method returns a {Geom::Vector2d} that is a unit vector
|
259
|
-
# of the {Geom::Vector2d}.
|
260
|
-
#
|
261
|
-
# @example
|
262
|
-
# vector = Geom::Vector2d.new(0, 4)
|
263
|
-
# # returns a new Vector2d(0, 1)
|
264
|
-
# vector2 = vector.normalize
|
265
|
-
#
|
266
|
-
# @return [Geom::Vector2d]
|
267
|
-
#
|
268
|
-
# @version LayOut 2018
|
269
|
-
def normalize
|
270
|
-
end
|
271
|
-
|
272
|
-
# The {#normalize!} method converts a {Geom::Vector2d} vector into a unit
|
273
|
-
# vector. Another way to do this is vector.length = 1
|
274
|
-
#
|
275
|
-
# @example
|
276
|
-
# vector = Geom::Vector2d.new(0, 4)
|
277
|
-
# # modifies vector to be the Vector2d(0, 1)
|
278
|
-
# vector.normalize!
|
279
|
-
#
|
280
|
-
# @version LayOut 2018
|
281
|
-
def normalize!
|
282
|
-
end
|
283
|
-
|
284
|
-
# The {#parallel?} method determines if the {Geom::Vector2d} is parallel to
|
285
|
-
# another {Geom::Vector2d} to within tolerance.
|
286
|
-
#
|
287
|
-
# @example
|
288
|
-
# vector = Geom::Vector2d.new(0, 1)
|
289
|
-
# vector2 = Geom::Vector2d.new(1, 2)
|
290
|
-
# # returns true
|
291
|
-
# status = vector.parallel?(vector2)
|
292
|
-
#
|
293
|
-
# @param [Geom::Vector2d] vector
|
294
|
-
#
|
295
|
-
# @return [Boolean]
|
296
|
-
#
|
297
|
-
# @version LayOut 2018
|
298
|
-
def parallel?(vector)
|
299
|
-
end
|
300
|
-
|
301
|
-
# The {#perpendicular?} method determines if the {Geom::Vector2d} is
|
302
|
-
# perpendicular to another {Geom::Vector2d} to within tolerance.
|
303
|
-
#
|
304
|
-
# @example
|
305
|
-
# vector = Geom::Vector2d.new(0, 1)
|
306
|
-
# vector2 = Geom::Vector2d.new(1, 2)
|
307
|
-
# # returns false
|
308
|
-
# status = vector.perpendicular?(vector2)
|
309
|
-
#
|
310
|
-
# @param [Geom::Vector2d] vector
|
311
|
-
#
|
312
|
-
# @return [Boolean]
|
313
|
-
#
|
314
|
-
# @version LayOut 2018
|
315
|
-
def perpendicular?(vector)
|
316
|
-
end
|
317
|
-
|
318
|
-
# The {#reverse} method returns a new {Geom::Vector2d} that is the reverse of
|
319
|
-
# the {Geom::Vector2d}, leaving the original unchanged.
|
320
|
-
#
|
321
|
-
# @example
|
322
|
-
# vector = Geom::Vector2d.new(1, 2)
|
323
|
-
# # returns the Vector2d(-1, -2)
|
324
|
-
# vector2 = vector.reverse
|
325
|
-
#
|
326
|
-
# @return [Geom::Vector2d]
|
327
|
-
#
|
328
|
-
# @version LayOut 2018
|
329
|
-
def reverse
|
330
|
-
end
|
331
|
-
|
332
|
-
# The {#reverse!} method reverses the {Geom::Vector2d} in place.
|
333
|
-
#
|
334
|
-
# @example
|
335
|
-
# vector = Geom::Vector2d.new(1, 2)
|
336
|
-
# # modifies vector to be the Vector2d(-1, -2)
|
337
|
-
# vector.reverse!
|
338
|
-
#
|
339
|
-
# @version LayOut 2018
|
340
|
-
def reverse!
|
341
|
-
end
|
342
|
-
|
343
|
-
# The {#same_direction?} method determines if the {Geom::Vector2d} is parallel
|
344
|
-
# to and in the same direction as another {Geom::Vector2d} within tolerance.
|
345
|
-
#
|
346
|
-
# @example
|
347
|
-
# vector = Geom::Vector2d.new(0, 1)
|
348
|
-
# vector2 = Geom::Vector2d.new(1, 2)
|
349
|
-
# # returns true
|
350
|
-
# status = vector.sime_direction?(vector2)
|
351
|
-
#
|
352
|
-
# @param [Geom::Vector2d] vector
|
353
|
-
#
|
354
|
-
# @return [Boolean]
|
355
|
-
#
|
356
|
-
# @version LayOut 2018
|
357
|
-
def same_direction?(vector)
|
358
|
-
end
|
359
|
-
|
360
|
-
# The {#set!} method sets the values of the {Geom::Vector2d}.
|
361
|
-
#
|
362
|
-
# @example
|
363
|
-
# vector = Geom::Vector2d.new(1, 2)
|
364
|
-
# vector = vector.set!([4, 5])
|
365
|
-
#
|
366
|
-
# @overload set!(vector)
|
367
|
-
#
|
368
|
-
# @param [Geom::Vector2d, Array(Numeric, Numeric)] vector
|
369
|
-
# @return [Geom::Vector2d]
|
370
|
-
#
|
371
|
-
# @overload set!(x, y)
|
372
|
-
#
|
373
|
-
# @param [Numeric] x
|
374
|
-
# @param [Numeric] y
|
375
|
-
# @return [Geom::Vector2d]
|
376
|
-
#
|
377
|
-
# @version LayOut 2018
|
378
|
-
def set!(*args)
|
379
|
-
end
|
380
|
-
|
381
|
-
# The {#to_a} method retrieves the coordinates of the {Geom::Vector2d} in an
|
382
|
-
# Array.
|
383
|
-
#
|
384
|
-
# @example
|
385
|
-
# a = vector.to_a
|
386
|
-
#
|
387
|
-
# @return [Array(Numeric, Numeric)]
|
388
|
-
#
|
389
|
-
# @version LayOut 2018
|
390
|
-
def to_a
|
391
|
-
end
|
392
|
-
|
393
|
-
# The {#to_s} method returns a string representation of the {Geom::Vector2d}.
|
394
|
-
#
|
395
|
-
# @example
|
396
|
-
# point = Geom::Vector2d.new(1, 2)
|
397
|
-
# str = point.to_s
|
398
|
-
#
|
399
|
-
# @return [String] the string representation of the {Geom::Vector2d}
|
400
|
-
#
|
401
|
-
# @version LayOut 2018
|
402
|
-
def to_s
|
403
|
-
end
|
404
|
-
|
405
|
-
# The {#transform} method applies a transformation to a vector, returning a new
|
406
|
-
# vector. The original vector is unchanged by this method.
|
407
|
-
#
|
408
|
-
# @example
|
409
|
-
# vector = Geom::Vector2d.new(4, 5)
|
410
|
-
# transformation = Geom::Transformation2d.new([1, 0, 0, 1, 2, 3])
|
411
|
-
# # vector2 will be (6, 8)
|
412
|
-
# vector2 = vector.transform(transformation)
|
413
|
-
#
|
414
|
-
# @param [Geom::Transformation2d] transform
|
415
|
-
# A transformation object to apply to the vector.
|
416
|
-
#
|
417
|
-
# @return [Geom::Vector2d] the newly transformed vector
|
418
|
-
#
|
419
|
-
# @version LayOut 2019
|
420
|
-
def transform(transform)
|
421
|
-
end
|
422
|
-
|
423
|
-
# The {#transform!} method applies a transformation to a vector. The vector
|
424
|
-
# itself is modified.
|
425
|
-
#
|
426
|
-
# @example
|
427
|
-
# vector = Geom::Vector2d.new(4, 5)
|
428
|
-
# transformation = Geom::Transformation2d.new([1, 0, 0, 1, 2, 3])
|
429
|
-
# # vector will be (6, 8)
|
430
|
-
# vector.transform!(transformation)
|
431
|
-
#
|
432
|
-
# @param [Geom::Transformation2d] transform
|
433
|
-
# A Transformation object to apply to the vector.
|
434
|
-
#
|
435
|
-
# @return [Geom::Vector2d] the transformed vector
|
436
|
-
#
|
437
|
-
# @version LayOut 2019
|
438
|
-
def transform!(transform)
|
439
|
-
end
|
440
|
-
|
441
|
-
# The {#unit_vector?} method returns whether the {Geom::Vector2d} is a unit
|
442
|
-
# vector. This is equivalent to vector.length == 1.0
|
443
|
-
#
|
444
|
-
# @example
|
445
|
-
# vector = Geom::Vector2d.new(1, 0)
|
446
|
-
# # returns true
|
447
|
-
# status = vector.unit_vector
|
448
|
-
#
|
449
|
-
# @return [Boolean]
|
450
|
-
#
|
451
|
-
# @version LayOut 2018
|
452
|
-
def unit_vector?
|
453
|
-
end
|
454
|
-
|
455
|
-
# The {#valid?} method verifies if a {Geom::Vector2d} is valid. A
|
456
|
-
# {Geom::Vector2d} is valid if its length is not zero.
|
457
|
-
#
|
458
|
-
# @example
|
459
|
-
# vector = Geom::Vector2d.new(0, 4)
|
460
|
-
# status = vector.valid
|
461
|
-
#
|
462
|
-
# @return [Boolean]
|
463
|
-
#
|
464
|
-
# @version LayOut 2018
|
465
|
-
def valid?
|
466
|
-
end
|
467
|
-
|
468
|
-
# The {#x} method retrieves the x value of the {Geom::Vector2d}.
|
469
|
-
#
|
470
|
-
# @example
|
471
|
-
# vector = Geom::Vector2d.new(1, 2)
|
472
|
-
# x = vector.x
|
473
|
-
#
|
474
|
-
# @return [Numeric]
|
475
|
-
#
|
476
|
-
# @version LayOut 2018
|
477
|
-
def x
|
478
|
-
end
|
479
|
-
|
480
|
-
# The {#x=} method sets the x coordinate of the {Geom::Vector2d}.
|
481
|
-
#
|
482
|
-
# @example
|
483
|
-
# vector = Geom::Vector2d.new(1, 2)
|
484
|
-
# vector.x = 7
|
485
|
-
#
|
486
|
-
# @param [Numeric] x
|
487
|
-
# The desired x value of the {Geom::Vector2d}
|
488
|
-
#
|
489
|
-
# @return [Numeric] The new x value of the {Geom::Vector2d}
|
490
|
-
#
|
491
|
-
# @version LayOut 2018
|
492
|
-
def x=(x)
|
493
|
-
end
|
494
|
-
|
495
|
-
# The {#y} method retrieves the y value of the {Geom::Vector2d}.
|
496
|
-
#
|
497
|
-
# @example
|
498
|
-
# vector = Geom::Vector2d.new(1, 2)
|
499
|
-
# y = vector.y
|
500
|
-
#
|
501
|
-
# @return [Numeric]
|
502
|
-
#
|
503
|
-
# @version LayOut 2018
|
504
|
-
def y
|
505
|
-
end
|
506
|
-
|
507
|
-
# The {#y=} method sets the y coordinate of the {Geom::Vector2d}.
|
508
|
-
#
|
509
|
-
# @example
|
510
|
-
# vector = Geom::Vector2d.new(1, 2)
|
511
|
-
# vector.y = 7
|
512
|
-
#
|
513
|
-
# @param [Numeric] y
|
514
|
-
# The desired y value of the {Geom::Vector2d}
|
515
|
-
#
|
516
|
-
# @return [Numeric] The new y value of the {Geom::Vector2d}
|
517
|
-
#
|
518
|
-
# @version LayOut 2018
|
519
|
-
def y=(y)
|
520
|
-
end
|
521
|
-
|
522
|
-
end
|
1
|
+
# Copyright:: Copyright 2023 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# The {Geom::Vector2d} class represents vectors in a 2 dimensional space.
|
5
|
+
#
|
6
|
+
# There are numerous tutorials on 2D vectors available on the internet.
|
7
|
+
#
|
8
|
+
# @version LayOut 2018
|
9
|
+
class Geom::Vector2d
|
10
|
+
|
11
|
+
# Instance Methods
|
12
|
+
|
13
|
+
# The {#%} method returns the dot product between two {Geom::Vector2d}. This is
|
14
|
+
# an alias of the dot method.
|
15
|
+
#
|
16
|
+
# @example
|
17
|
+
# vector = Geom::Vector2d.new(0, 2)
|
18
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
19
|
+
# d2 = vector % vector2
|
20
|
+
#
|
21
|
+
# @param [Geom::Vector2d] vector
|
22
|
+
#
|
23
|
+
# @return The dot product of the vectors
|
24
|
+
#
|
25
|
+
# @version LayOut 2018
|
26
|
+
def %(vector)
|
27
|
+
end
|
28
|
+
|
29
|
+
# The {#*} method returns the cross product between two {Geom::Vector2d}. This
|
30
|
+
# is an alias of the cross method.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# vector = Geom::Vector2d.new(1, 0)
|
34
|
+
# vector2 = Geom::Vector2d.new(0, 1)
|
35
|
+
# cross = vector * vector
|
36
|
+
#
|
37
|
+
# @param [Geom::Vector2d] vector
|
38
|
+
#
|
39
|
+
# @return [Geom::Vector2d]
|
40
|
+
#
|
41
|
+
# @version LayOut 2018
|
42
|
+
def *(vector)
|
43
|
+
end
|
44
|
+
|
45
|
+
# The {#+} method adds a {Geom::Vector2d} to this one.
|
46
|
+
#
|
47
|
+
# @example
|
48
|
+
# vector = Geom::Vector2d.new(0, 2)
|
49
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
50
|
+
# new_vector = vector + vector2
|
51
|
+
#
|
52
|
+
# @param [Geom::Vector2d] vector
|
53
|
+
#
|
54
|
+
# @return [Geom::Vector2d]
|
55
|
+
#
|
56
|
+
# @version LayOut 2018
|
57
|
+
def +(vector)
|
58
|
+
end
|
59
|
+
|
60
|
+
# The {#-} method subtracts a {Geom::Vector2d} from this one.
|
61
|
+
#
|
62
|
+
# @example
|
63
|
+
# vector = Geom::Vector2d.new(0, 2)
|
64
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
65
|
+
# new_vector = vector - vector2
|
66
|
+
#
|
67
|
+
# @param [Geom::Vector2d] vector
|
68
|
+
#
|
69
|
+
# @return [Geom::Vector2d]
|
70
|
+
#
|
71
|
+
# @version LayOut 2018
|
72
|
+
def -(vector)
|
73
|
+
end
|
74
|
+
|
75
|
+
# The {#==} method returns whether two {Geom::Vector2d} are equal within
|
76
|
+
# tolerance.
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# vector = Geom::Vector2d.new(1, 0)
|
80
|
+
# vector2 = Geom::Vector2d.new(0,1)
|
81
|
+
# # Returns false
|
82
|
+
# status = vector == vector2
|
83
|
+
#
|
84
|
+
# @param [Geom::Vector2d] vector
|
85
|
+
#
|
86
|
+
# @return [Boolean]
|
87
|
+
#
|
88
|
+
# @version LayOut 2018
|
89
|
+
def ==(vector)
|
90
|
+
end
|
91
|
+
|
92
|
+
# The {#[]} method returns the value of the {Geom::Vector2d} at the specified
|
93
|
+
# index.
|
94
|
+
#
|
95
|
+
# @example
|
96
|
+
# vector = Geom::Vector2d.new(1, 2)
|
97
|
+
# # retrieves the y value of 2
|
98
|
+
# yvalue = vector[1]
|
99
|
+
#
|
100
|
+
# @param [Integer] index
|
101
|
+
# The index into an array of two coordinates.
|
102
|
+
#
|
103
|
+
# @return [Numeric] The value for the x or y coordinate.
|
104
|
+
#
|
105
|
+
# @version LayOut 2018
|
106
|
+
def [](index)
|
107
|
+
end
|
108
|
+
|
109
|
+
# The {#[]=} method sets the x or y value of the {Geom::Vector2d} based on the
|
110
|
+
# specific index of the value.
|
111
|
+
#
|
112
|
+
# @example
|
113
|
+
# point = Geom::Vector2d.new(1,2)
|
114
|
+
# point[1] = 4
|
115
|
+
#
|
116
|
+
# @param [Numeric] index
|
117
|
+
# The index for a specific x or y value in the
|
118
|
+
# {Geom::Vector2d} to set
|
119
|
+
#
|
120
|
+
# @param [Numeric] value
|
121
|
+
# The value to set for x or y
|
122
|
+
#
|
123
|
+
# @return [Numeric] The new x or y value if successful
|
124
|
+
#
|
125
|
+
# @version LayOut 2018
|
126
|
+
def []=(index, value)
|
127
|
+
end
|
128
|
+
|
129
|
+
# The {#angle_between} method computes the angle in radians between
|
130
|
+
# the {Geom::Vector2d} and another {Geom::Vector2d}.
|
131
|
+
#
|
132
|
+
# @example
|
133
|
+
# vector = Geom::Vector2d.new(1, 0)
|
134
|
+
# vector2 = Geom::Vector2d.new(-1, 0)
|
135
|
+
# # returns PI
|
136
|
+
# angle = vector.angle_between(vector2)
|
137
|
+
#
|
138
|
+
# @param [Geom::Vector2d] vector
|
139
|
+
#
|
140
|
+
# @return [Numeric] The angle (in radians)
|
141
|
+
#
|
142
|
+
# @version LayOut 2018
|
143
|
+
def angle_between(vector)
|
144
|
+
end
|
145
|
+
|
146
|
+
# The {#clone} method makes a copy of the {Geom::Vector2d}. This method is
|
147
|
+
# equivalent to vec2 = Geom::Vector2d.new(vec).
|
148
|
+
#
|
149
|
+
# @example
|
150
|
+
# vector = Geom::Vector2d.new(1, 0)
|
151
|
+
# vector2 = vector.clone
|
152
|
+
#
|
153
|
+
# @return [Geom::Vector2d]
|
154
|
+
#
|
155
|
+
# @version LayOut 2018
|
156
|
+
def clone
|
157
|
+
end
|
158
|
+
|
159
|
+
# The {#*} method returns the cross product between two {Geom::Vector2d}. This
|
160
|
+
# is an alias of the cross method.
|
161
|
+
#
|
162
|
+
# @example
|
163
|
+
# vector = Geom::Vector2d.new(1, 0)
|
164
|
+
# vector2 = Geom::Vector2d.new(0, 1)
|
165
|
+
# cross = vector * vector
|
166
|
+
#
|
167
|
+
# @param [Geom::Vector2d] vector
|
168
|
+
#
|
169
|
+
# @return [Geom::Vector2d]
|
170
|
+
#
|
171
|
+
# @version LayOut 2018
|
172
|
+
def cross(vector)
|
173
|
+
end
|
174
|
+
|
175
|
+
# The {#%} method returns the dot product between two {Geom::Vector2d}. This is
|
176
|
+
# an alias of the dot method.
|
177
|
+
#
|
178
|
+
# @example
|
179
|
+
# vector = Geom::Vector2d.new(0, 2)
|
180
|
+
# vector2 = Geom::Vector2d.new(1, 0)
|
181
|
+
# d2 = vector % vector2
|
182
|
+
#
|
183
|
+
# @param [Geom::Vector2d] vector
|
184
|
+
#
|
185
|
+
# @return The dot product of the vectors
|
186
|
+
#
|
187
|
+
# @version LayOut 2018
|
188
|
+
def dot(vector)
|
189
|
+
end
|
190
|
+
|
191
|
+
# The {.new} method creates a new {Geom::Vector2d}.
|
192
|
+
#
|
193
|
+
# @example
|
194
|
+
# # A vector that runs along the X axis.
|
195
|
+
# vector = Geom::Vector2d.new(1, 0)
|
196
|
+
#
|
197
|
+
# @overload initialize
|
198
|
+
#
|
199
|
+
# @return [Geom::Vector2d]
|
200
|
+
#
|
201
|
+
# @overload initialize(x, y)
|
202
|
+
#
|
203
|
+
# @param [Numeric] x The length in the x direction
|
204
|
+
# @param [Numeric] y The length in the y direction
|
205
|
+
# @return [Geom::Vector2d]
|
206
|
+
#
|
207
|
+
# @overload initialize(vector)
|
208
|
+
#
|
209
|
+
# @param [Geom::Vector2d, Array(Numeric, Numeric)] vector
|
210
|
+
# @return [Geom::Vector2d]
|
211
|
+
#
|
212
|
+
# @version LayOut 2018
|
213
|
+
def initialize(*args)
|
214
|
+
end
|
215
|
+
|
216
|
+
# The {#inspect} method formats the {Geom::Vector2d} as a string.
|
217
|
+
#
|
218
|
+
# @example
|
219
|
+
# point = Geom::Point2d.new(1, 2)
|
220
|
+
# string = point.inspect
|
221
|
+
#
|
222
|
+
# @return [String] the string representation of the {Geom::Vector2d}
|
223
|
+
#
|
224
|
+
# @version LayOut 2018
|
225
|
+
def inspect
|
226
|
+
end
|
227
|
+
|
228
|
+
# The {#length} method returns the length of the {Geom::Vector2d}.
|
229
|
+
#
|
230
|
+
# @example
|
231
|
+
# vector = Geom::Vector2d.new(0, 4)
|
232
|
+
# # returns 4
|
233
|
+
# l = vector.length
|
234
|
+
#
|
235
|
+
# @return [Length] The length of the {Geom::Vector2d}
|
236
|
+
#
|
237
|
+
# @version LayOut 2018
|
238
|
+
def length
|
239
|
+
end
|
240
|
+
|
241
|
+
# The {#length=} method sets the length of the {Geom::Vector2d}. The new length
|
242
|
+
# must not be 0.
|
243
|
+
#
|
244
|
+
# @example
|
245
|
+
# vector = Geom::Vector2d.new(0, 4)
|
246
|
+
# l = vector.length
|
247
|
+
# vector.length = 2
|
248
|
+
#
|
249
|
+
# @param [Numeric] length
|
250
|
+
# The new length for the {Geom::Vector2d}
|
251
|
+
#
|
252
|
+
# @return [Numeric] The new length
|
253
|
+
#
|
254
|
+
# @version LayOut 2018
|
255
|
+
def length=(length)
|
256
|
+
end
|
257
|
+
|
258
|
+
# The {#normalize} method returns a {Geom::Vector2d} that is a unit vector
|
259
|
+
# of the {Geom::Vector2d}.
|
260
|
+
#
|
261
|
+
# @example
|
262
|
+
# vector = Geom::Vector2d.new(0, 4)
|
263
|
+
# # returns a new Vector2d(0, 1)
|
264
|
+
# vector2 = vector.normalize
|
265
|
+
#
|
266
|
+
# @return [Geom::Vector2d]
|
267
|
+
#
|
268
|
+
# @version LayOut 2018
|
269
|
+
def normalize
|
270
|
+
end
|
271
|
+
|
272
|
+
# The {#normalize!} method converts a {Geom::Vector2d} vector into a unit
|
273
|
+
# vector. Another way to do this is vector.length = 1
|
274
|
+
#
|
275
|
+
# @example
|
276
|
+
# vector = Geom::Vector2d.new(0, 4)
|
277
|
+
# # modifies vector to be the Vector2d(0, 1)
|
278
|
+
# vector.normalize!
|
279
|
+
#
|
280
|
+
# @version LayOut 2018
|
281
|
+
def normalize!
|
282
|
+
end
|
283
|
+
|
284
|
+
# The {#parallel?} method determines if the {Geom::Vector2d} is parallel to
|
285
|
+
# another {Geom::Vector2d} to within tolerance.
|
286
|
+
#
|
287
|
+
# @example
|
288
|
+
# vector = Geom::Vector2d.new(0, 1)
|
289
|
+
# vector2 = Geom::Vector2d.new(1, 2)
|
290
|
+
# # returns true
|
291
|
+
# status = vector.parallel?(vector2)
|
292
|
+
#
|
293
|
+
# @param [Geom::Vector2d] vector
|
294
|
+
#
|
295
|
+
# @return [Boolean]
|
296
|
+
#
|
297
|
+
# @version LayOut 2018
|
298
|
+
def parallel?(vector)
|
299
|
+
end
|
300
|
+
|
301
|
+
# The {#perpendicular?} method determines if the {Geom::Vector2d} is
|
302
|
+
# perpendicular to another {Geom::Vector2d} to within tolerance.
|
303
|
+
#
|
304
|
+
# @example
|
305
|
+
# vector = Geom::Vector2d.new(0, 1)
|
306
|
+
# vector2 = Geom::Vector2d.new(1, 2)
|
307
|
+
# # returns false
|
308
|
+
# status = vector.perpendicular?(vector2)
|
309
|
+
#
|
310
|
+
# @param [Geom::Vector2d] vector
|
311
|
+
#
|
312
|
+
# @return [Boolean]
|
313
|
+
#
|
314
|
+
# @version LayOut 2018
|
315
|
+
def perpendicular?(vector)
|
316
|
+
end
|
317
|
+
|
318
|
+
# The {#reverse} method returns a new {Geom::Vector2d} that is the reverse of
|
319
|
+
# the {Geom::Vector2d}, leaving the original unchanged.
|
320
|
+
#
|
321
|
+
# @example
|
322
|
+
# vector = Geom::Vector2d.new(1, 2)
|
323
|
+
# # returns the Vector2d(-1, -2)
|
324
|
+
# vector2 = vector.reverse
|
325
|
+
#
|
326
|
+
# @return [Geom::Vector2d]
|
327
|
+
#
|
328
|
+
# @version LayOut 2018
|
329
|
+
def reverse
|
330
|
+
end
|
331
|
+
|
332
|
+
# The {#reverse!} method reverses the {Geom::Vector2d} in place.
|
333
|
+
#
|
334
|
+
# @example
|
335
|
+
# vector = Geom::Vector2d.new(1, 2)
|
336
|
+
# # modifies vector to be the Vector2d(-1, -2)
|
337
|
+
# vector.reverse!
|
338
|
+
#
|
339
|
+
# @version LayOut 2018
|
340
|
+
def reverse!
|
341
|
+
end
|
342
|
+
|
343
|
+
# The {#same_direction?} method determines if the {Geom::Vector2d} is parallel
|
344
|
+
# to and in the same direction as another {Geom::Vector2d} within tolerance.
|
345
|
+
#
|
346
|
+
# @example
|
347
|
+
# vector = Geom::Vector2d.new(0, 1)
|
348
|
+
# vector2 = Geom::Vector2d.new(1, 2)
|
349
|
+
# # returns true
|
350
|
+
# status = vector.sime_direction?(vector2)
|
351
|
+
#
|
352
|
+
# @param [Geom::Vector2d] vector
|
353
|
+
#
|
354
|
+
# @return [Boolean]
|
355
|
+
#
|
356
|
+
# @version LayOut 2018
|
357
|
+
def same_direction?(vector)
|
358
|
+
end
|
359
|
+
|
360
|
+
# The {#set!} method sets the values of the {Geom::Vector2d}.
|
361
|
+
#
|
362
|
+
# @example
|
363
|
+
# vector = Geom::Vector2d.new(1, 2)
|
364
|
+
# vector = vector.set!([4, 5])
|
365
|
+
#
|
366
|
+
# @overload set!(vector)
|
367
|
+
#
|
368
|
+
# @param [Geom::Vector2d, Array(Numeric, Numeric)] vector
|
369
|
+
# @return [Geom::Vector2d]
|
370
|
+
#
|
371
|
+
# @overload set!(x, y)
|
372
|
+
#
|
373
|
+
# @param [Numeric] x
|
374
|
+
# @param [Numeric] y
|
375
|
+
# @return [Geom::Vector2d]
|
376
|
+
#
|
377
|
+
# @version LayOut 2018
|
378
|
+
def set!(*args)
|
379
|
+
end
|
380
|
+
|
381
|
+
# The {#to_a} method retrieves the coordinates of the {Geom::Vector2d} in an
|
382
|
+
# Array.
|
383
|
+
#
|
384
|
+
# @example
|
385
|
+
# a = vector.to_a
|
386
|
+
#
|
387
|
+
# @return [Array(Numeric, Numeric)]
|
388
|
+
#
|
389
|
+
# @version LayOut 2018
|
390
|
+
def to_a
|
391
|
+
end
|
392
|
+
|
393
|
+
# The {#to_s} method returns a string representation of the {Geom::Vector2d}.
|
394
|
+
#
|
395
|
+
# @example
|
396
|
+
# point = Geom::Vector2d.new(1, 2)
|
397
|
+
# str = point.to_s
|
398
|
+
#
|
399
|
+
# @return [String] the string representation of the {Geom::Vector2d}
|
400
|
+
#
|
401
|
+
# @version LayOut 2018
|
402
|
+
def to_s
|
403
|
+
end
|
404
|
+
|
405
|
+
# The {#transform} method applies a transformation to a vector, returning a new
|
406
|
+
# vector. The original vector is unchanged by this method.
|
407
|
+
#
|
408
|
+
# @example
|
409
|
+
# vector = Geom::Vector2d.new(4, 5)
|
410
|
+
# transformation = Geom::Transformation2d.new([1, 0, 0, 1, 2, 3])
|
411
|
+
# # vector2 will be (6, 8)
|
412
|
+
# vector2 = vector.transform(transformation)
|
413
|
+
#
|
414
|
+
# @param [Geom::Transformation2d] transform
|
415
|
+
# A transformation object to apply to the vector.
|
416
|
+
#
|
417
|
+
# @return [Geom::Vector2d] the newly transformed vector
|
418
|
+
#
|
419
|
+
# @version LayOut 2019
|
420
|
+
def transform(transform)
|
421
|
+
end
|
422
|
+
|
423
|
+
# The {#transform!} method applies a transformation to a vector. The vector
|
424
|
+
# itself is modified.
|
425
|
+
#
|
426
|
+
# @example
|
427
|
+
# vector = Geom::Vector2d.new(4, 5)
|
428
|
+
# transformation = Geom::Transformation2d.new([1, 0, 0, 1, 2, 3])
|
429
|
+
# # vector will be (6, 8)
|
430
|
+
# vector.transform!(transformation)
|
431
|
+
#
|
432
|
+
# @param [Geom::Transformation2d] transform
|
433
|
+
# A Transformation object to apply to the vector.
|
434
|
+
#
|
435
|
+
# @return [Geom::Vector2d] the transformed vector
|
436
|
+
#
|
437
|
+
# @version LayOut 2019
|
438
|
+
def transform!(transform)
|
439
|
+
end
|
440
|
+
|
441
|
+
# The {#unit_vector?} method returns whether the {Geom::Vector2d} is a unit
|
442
|
+
# vector. This is equivalent to vector.length == 1.0
|
443
|
+
#
|
444
|
+
# @example
|
445
|
+
# vector = Geom::Vector2d.new(1, 0)
|
446
|
+
# # returns true
|
447
|
+
# status = vector.unit_vector
|
448
|
+
#
|
449
|
+
# @return [Boolean]
|
450
|
+
#
|
451
|
+
# @version LayOut 2018
|
452
|
+
def unit_vector?
|
453
|
+
end
|
454
|
+
|
455
|
+
# The {#valid?} method verifies if a {Geom::Vector2d} is valid. A
|
456
|
+
# {Geom::Vector2d} is valid if its length is not zero.
|
457
|
+
#
|
458
|
+
# @example
|
459
|
+
# vector = Geom::Vector2d.new(0, 4)
|
460
|
+
# status = vector.valid
|
461
|
+
#
|
462
|
+
# @return [Boolean]
|
463
|
+
#
|
464
|
+
# @version LayOut 2018
|
465
|
+
def valid?
|
466
|
+
end
|
467
|
+
|
468
|
+
# The {#x} method retrieves the x value of the {Geom::Vector2d}.
|
469
|
+
#
|
470
|
+
# @example
|
471
|
+
# vector = Geom::Vector2d.new(1, 2)
|
472
|
+
# x = vector.x
|
473
|
+
#
|
474
|
+
# @return [Numeric]
|
475
|
+
#
|
476
|
+
# @version LayOut 2018
|
477
|
+
def x
|
478
|
+
end
|
479
|
+
|
480
|
+
# The {#x=} method sets the x coordinate of the {Geom::Vector2d}.
|
481
|
+
#
|
482
|
+
# @example
|
483
|
+
# vector = Geom::Vector2d.new(1, 2)
|
484
|
+
# vector.x = 7
|
485
|
+
#
|
486
|
+
# @param [Numeric] x
|
487
|
+
# The desired x value of the {Geom::Vector2d}
|
488
|
+
#
|
489
|
+
# @return [Numeric] The new x value of the {Geom::Vector2d}
|
490
|
+
#
|
491
|
+
# @version LayOut 2018
|
492
|
+
def x=(x)
|
493
|
+
end
|
494
|
+
|
495
|
+
# The {#y} method retrieves the y value of the {Geom::Vector2d}.
|
496
|
+
#
|
497
|
+
# @example
|
498
|
+
# vector = Geom::Vector2d.new(1, 2)
|
499
|
+
# y = vector.y
|
500
|
+
#
|
501
|
+
# @return [Numeric]
|
502
|
+
#
|
503
|
+
# @version LayOut 2018
|
504
|
+
def y
|
505
|
+
end
|
506
|
+
|
507
|
+
# The {#y=} method sets the y coordinate of the {Geom::Vector2d}.
|
508
|
+
#
|
509
|
+
# @example
|
510
|
+
# vector = Geom::Vector2d.new(1, 2)
|
511
|
+
# vector.y = 7
|
512
|
+
#
|
513
|
+
# @param [Numeric] y
|
514
|
+
# The desired y value of the {Geom::Vector2d}
|
515
|
+
#
|
516
|
+
# @return [Numeric] The new y value of the {Geom::Vector2d}
|
517
|
+
#
|
518
|
+
# @version LayOut 2018
|
519
|
+
def y=(y)
|
520
|
+
end
|
521
|
+
|
522
|
+
end
|