sketchup-api-stubs 0.6.1 → 0.7.4
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/.yardopts +2 -0
- data/lib/sketchup-api-stubs.rb +1 -1
- data/lib/sketchup-api-stubs/sketchup.rb +145 -145
- data/lib/sketchup-api-stubs/stubs/Geom/BoundingBox.rb +318 -318
- 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 -401
- data/lib/sketchup-api-stubs/stubs/Geom/Point3d.rb +661 -661
- data/lib/sketchup-api-stubs/stubs/Geom/PolygonMesh.rb +492 -492
- data/lib/sketchup-api-stubs/stubs/Geom/Transformation.rb +478 -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 -523
- data/lib/sketchup-api-stubs/stubs/Geom/Vector3d.rb +691 -691
- data/lib/sketchup-api-stubs/stubs/Layout.rb +25 -25
- data/lib/sketchup-api-stubs/stubs/Layout/AngularDimension.rb +573 -569
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinition.rb +411 -411
- data/lib/sketchup-api-stubs/stubs/Layout/AutoTextDefinitions.rb +174 -186
- data/lib/sketchup-api-stubs/stubs/Layout/ConnectionPoint.rb +70 -70
- data/lib/sketchup-api-stubs/stubs/Layout/Document.rb +514 -455
- data/lib/sketchup-api-stubs/stubs/Layout/Ellipse.rb +29 -29
- data/lib/sketchup-api-stubs/stubs/Layout/Entities.rb +143 -155
- data/lib/sketchup-api-stubs/stubs/Layout/Entity.rb +353 -359
- data/lib/sketchup-api-stubs/stubs/Layout/FormattedText.rb +349 -349
- data/lib/sketchup-api-stubs/stubs/Layout/Grid.rb +311 -123
- data/lib/sketchup-api-stubs/stubs/Layout/Group.rb +261 -261
- data/lib/sketchup-api-stubs/stubs/Layout/Image.rb +91 -86
- data/lib/sketchup-api-stubs/stubs/Layout/Label.rb +371 -371
- 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 +220 -232
- data/lib/sketchup-api-stubs/stubs/Layout/LinearDimension.rb +567 -563
- 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 +204 -216
- 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/SketchUpModel.rb +694 -547
- 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/Sketchup/Animation.rb +140 -140
- data/lib/sketchup-api-stubs/stubs/Sketchup/AppObserver.rb +157 -157
- data/lib/sketchup-api-stubs/stubs/Sketchup/ArcCurve.rb +209 -209
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionaries.rb +152 -152
- data/lib/sketchup-api-stubs/stubs/Sketchup/AttributeDictionary.rb +281 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/Axes.rb +149 -149
- data/lib/sketchup-api-stubs/stubs/Sketchup/Behavior.rb +328 -328
- data/lib/sketchup-api-stubs/stubs/Sketchup/Camera.rb +577 -577
- data/lib/sketchup-api-stubs/stubs/Sketchup/ClassificationSchema.rb +63 -63
- data/lib/sketchup-api-stubs/stubs/Sketchup/Classifications.rb +122 -122
- data/lib/sketchup-api-stubs/stubs/Sketchup/Color.rb +281 -281
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentDefinition.rb +562 -554
- data/lib/sketchup-api-stubs/stubs/Sketchup/ComponentInstance.rb +593 -593
- 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 +194 -194
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionList.rb +329 -329
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionObserver.rb +72 -72
- data/lib/sketchup-api-stubs/stubs/Sketchup/DefinitionsObserver.rb +102 -102
- data/lib/sketchup-api-stubs/stubs/Sketchup/Dimension.rb +165 -165
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionLinear.rb +312 -312
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionObserver.rb +38 -38
- data/lib/sketchup-api-stubs/stubs/Sketchup/DimensionRadial.rb +87 -87
- data/lib/sketchup-api-stubs/stubs/Sketchup/Drawingelement.rb +390 -390
- data/lib/sketchup-api-stubs/stubs/Sketchup/Edge.rb +508 -508
- data/lib/sketchup-api-stubs/stubs/Sketchup/EdgeUse.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entities.rb +1119 -1097
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntitiesObserver.rb +125 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Entity.rb +544 -537
- data/lib/sketchup-api-stubs/stubs/Sketchup/EntityObserver.rb +59 -59
- data/lib/sketchup-api-stubs/stubs/Sketchup/ExtensionsManager.rb +125 -125
- data/lib/sketchup-api-stubs/stubs/Sketchup/Face.rb +750 -750
- data/lib/sketchup-api-stubs/stubs/Sketchup/FrameChangeObserver.rb +104 -104
- data/lib/sketchup-api-stubs/stubs/Sketchup/Group.rb +697 -697
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http.rb +27 -27
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Request.rb +285 -285
- data/lib/sketchup-api-stubs/stubs/Sketchup/Http/Response.rb +62 -62
- data/lib/sketchup-api-stubs/stubs/Sketchup/Image.rb +409 -409
- data/lib/sketchup-api-stubs/stubs/Sketchup/ImageRep.rb +226 -226
- data/lib/sketchup-api-stubs/stubs/Sketchup/Importer.rb +190 -190
- data/lib/sketchup-api-stubs/stubs/Sketchup/InputPoint.rb +393 -393
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstanceObserver.rb +82 -82
- data/lib/sketchup-api-stubs/stubs/Sketchup/InstancePath.rb +303 -303
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layer.rb +285 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Layers.rb +244 -231
- data/lib/sketchup-api-stubs/stubs/Sketchup/LayersObserver.rb +136 -136
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing.rb +48 -48
- data/lib/sketchup-api-stubs/stubs/Sketchup/Licensing/ExtensionLicense.rb +86 -86
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyle.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/Sketchup/LineStyles.rb +112 -123
- data/lib/sketchup-api-stubs/stubs/Sketchup/Loop.rb +137 -137
- data/lib/sketchup-api-stubs/stubs/Sketchup/Material.rb +416 -416
- data/lib/sketchup-api-stubs/stubs/Sketchup/Materials.rb +311 -311
- data/lib/sketchup-api-stubs/stubs/Sketchup/MaterialsObserver.rb +141 -141
- data/lib/sketchup-api-stubs/stubs/Sketchup/Menu.rb +95 -95
- data/lib/sketchup-api-stubs/stubs/Sketchup/Model.rb +1638 -1483
- data/lib/sketchup-api-stubs/stubs/Sketchup/ModelObserver.rb +356 -356
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsManager.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProvider.rb +284 -282
- data/lib/sketchup-api-stubs/stubs/Sketchup/OptionsProviderObserver.rb +58 -58
- data/lib/sketchup-api-stubs/stubs/Sketchup/Page.rb +770 -650
- data/lib/sketchup-api-stubs/stubs/Sketchup/Pages.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/Sketchup/PagesObserver.rb +76 -76
- data/lib/sketchup-api-stubs/stubs/Sketchup/PickHelper.rb +456 -456
- data/lib/sketchup-api-stubs/stubs/Sketchup/RegionalSettings.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptions.rb +364 -356
- data/lib/sketchup-api-stubs/stubs/Sketchup/RenderingOptionsObserver.rb +44 -44
- data/lib/sketchup-api-stubs/stubs/Sketchup/SectionPlane.rb +150 -150
- data/lib/sketchup-api-stubs/stubs/Sketchup/Selection.rb +454 -454
- 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 +257 -257
- data/lib/sketchup-api-stubs/stubs/Sketchup/ShadowInfoObserver.rb +57 -57
- data/lib/sketchup-api-stubs/stubs/Sketchup/Style.rb +69 -69
- data/lib/sketchup-api-stubs/stubs/Sketchup/Styles.rb +211 -211
- data/lib/sketchup-api-stubs/stubs/Sketchup/Text.rb +262 -262
- data/lib/sketchup-api-stubs/stubs/Sketchup/Texture.rb +225 -225
- data/lib/sketchup-api-stubs/stubs/Sketchup/TextureWriter.rb +237 -237
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tool.rb +829 -829
- data/lib/sketchup-api-stubs/stubs/Sketchup/Tools.rb +132 -132
- data/lib/sketchup-api-stubs/stubs/Sketchup/ToolsObserver.rb +154 -154
- data/lib/sketchup-api-stubs/stubs/Sketchup/UVHelper.rb +61 -61
- data/lib/sketchup-api-stubs/stubs/Sketchup/Vertex.rb +142 -142
- data/lib/sketchup-api-stubs/stubs/Sketchup/View.rb +1301 -995
- data/lib/sketchup-api-stubs/stubs/Sketchup/ViewObserver.rb +43 -43
- data/lib/sketchup-api-stubs/stubs/UI/Command.rb +310 -310
- data/lib/sketchup-api-stubs/stubs/UI/HtmlDialog.rb +356 -356
- data/lib/sketchup-api-stubs/stubs/UI/Notification.rb +229 -229
- data/lib/sketchup-api-stubs/stubs/UI/Toolbar.rb +240 -240
- data/lib/sketchup-api-stubs/stubs/UI/WebDialog.rb +633 -633
- data/lib/sketchup-api-stubs/stubs/_top_level.rb +311 -303
- data/lib/sketchup-api-stubs/stubs/array.rb +741 -741
- data/lib/sketchup-api-stubs/stubs/geom.rb +348 -233
- data/lib/sketchup-api-stubs/stubs/languagehandler.rb +92 -92
- data/lib/sketchup-api-stubs/stubs/length.rb +278 -262
- data/lib/sketchup-api-stubs/stubs/numeric.rb +249 -249
- data/lib/sketchup-api-stubs/stubs/sketchup.rb +1310 -1310
- data/lib/sketchup-api-stubs/stubs/sketchupextension.rb +353 -353
- data/lib/sketchup-api-stubs/stubs/string.rb +24 -24
- data/lib/sketchup-api-stubs/stubs/ui.rb +667 -660
- metadata +2 -16
@@ -1,691 +1,691 @@
|
|
1
|
-
# Copyright:: Copyright
|
2
|
-
# License:: The MIT License (MIT)
|
3
|
-
|
4
|
-
# The Vector3d class is used to represent vectors in a 3 dimensional space.
|
5
|
-
# Vectors in SketchUp have a direction and a length, but not a starting point.
|
6
|
-
#
|
7
|
-
# There are numerous tutorials on 3D vectors available on the internet.
|
8
|
-
#
|
9
|
-
# @version SketchUp 6.0
|
10
|
-
class Geom::Vector3d
|
11
|
-
|
12
|
-
# Class Methods
|
13
|
-
|
14
|
-
# The {.linear_combination} method is used to create a new vector as a linear
|
15
|
-
# combination of other vectors. This method is generally used to get a vector
|
16
|
-
# at some percentage between two vectors.
|
17
|
-
#
|
18
|
-
# A linear combination is a standard term for vector math. It is defined as
|
19
|
-
# vector = weight1 * vector1 + weight2 * vector2.
|
20
|
-
#
|
21
|
-
# @example
|
22
|
-
# # Create a vector that is a 50%/50% linear combination of two others.
|
23
|
-
# vec1 = Geom::Vector3d.new 3,0,0
|
24
|
-
# vec2 = Geom::Vector3d.new 0,3,0
|
25
|
-
# new_vector = Geom::Vector3d.linear_combination(0.5, vec1, 0.5, vec2)
|
26
|
-
# # new_vector will now contain a Vector3d(1.5, 1.5, 0)
|
27
|
-
#
|
28
|
-
# @overload linear_combination(weight1, vector1, weight2, vector2)
|
29
|
-
#
|
30
|
-
# @param [Numeric] weight1 A weight or percentage.
|
31
|
-
# @param [Geom::Vector3d] vector1 The first vector.
|
32
|
-
# @param [Numeric] weight2 A weight or percentage.
|
33
|
-
# @param [Geom::Vector3d] vector2 The second vector.
|
34
|
-
# @return [Geom::Vector3d]
|
35
|
-
#
|
36
|
-
# @overload linear_combination(x, xaxis, y, yaxis, z, zaxis)
|
37
|
-
#
|
38
|
-
# @param [Numeric] x A weight or percentage for the x axis.
|
39
|
-
# @param [Geom::Vector3d] xaxis The x axis vector.
|
40
|
-
# @param [Numeric] y A weight or percentage for the y axis.
|
41
|
-
# @param [Geom::Vector3d] yaxis The y axis vector.
|
42
|
-
# @param [Numeric] z A weight or percentage for the z axis.
|
43
|
-
# @param [Geom::Vector3d] zaxis The z axis vector.
|
44
|
-
# @return [Geom::Vector3d]
|
45
|
-
#
|
46
|
-
# @version SketchUp 6.0
|
47
|
-
def self.linear_combination(*args)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Instance Methods
|
51
|
-
|
52
|
-
# The {#%} method is used to compute the dot product between two vectors.
|
53
|
-
#
|
54
|
-
# This is an alias of the {#dot} method.
|
55
|
-
#
|
56
|
-
# @example
|
57
|
-
# vector1 = Geom::Vector3d.new(0, 0, 1)
|
58
|
-
# vector2 = Geom::Vector3d.new(0, 1, 0)
|
59
|
-
# dot = vector1 % vector2
|
60
|
-
#
|
61
|
-
# @param [Geom::Vector] vector
|
62
|
-
#
|
63
|
-
# @return [Float]
|
64
|
-
#
|
65
|
-
# @see #dot
|
66
|
-
#
|
67
|
-
# @version SketchUp 6.0
|
68
|
-
def %(vector)
|
69
|
-
end
|
70
|
-
|
71
|
-
# The {#cross} method is used to compute the cross product between two vectors.
|
72
|
-
#
|
73
|
-
# The cross product, also called the vector product, is an operation on two
|
74
|
-
# vectors. The cross product of two vectors produces a third vector which is
|
75
|
-
# perpendicular to the plane in which the first two lie.
|
76
|
-
#
|
77
|
-
# @example
|
78
|
-
# vector1 = Geom::Vector3d.new(1,0,0)
|
79
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
80
|
-
# vector3 = vector1 * vector2
|
81
|
-
#
|
82
|
-
# @example
|
83
|
-
# vector = Geom::Vector3d.new(1,0,0)
|
84
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
85
|
-
# vector3 = vector.cross(vector2)
|
86
|
-
#
|
87
|
-
# @param [Geom::Vector3d] vector
|
88
|
-
# A Vector3d object.
|
89
|
-
#
|
90
|
-
# @return [Geom::Vector3d] the cross of vector1 and vector2
|
91
|
-
#
|
92
|
-
# @see #*
|
93
|
-
#
|
94
|
-
# @version SketchUp 6.0
|
95
|
-
def *(vector)
|
96
|
-
end
|
97
|
-
|
98
|
-
# The - method is used to add a vector to this one.
|
99
|
-
#
|
100
|
-
# @example
|
101
|
-
# vector = Geom::Vector3d.new(0,0,2)
|
102
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
103
|
-
# new_vector = vector + vector2
|
104
|
-
#
|
105
|
-
# @param vector2
|
106
|
-
# A Vector3d object.
|
107
|
-
#
|
108
|
-
# @return [Geom::Vector3d] the new vector.
|
109
|
-
#
|
110
|
-
# @version SketchUp 6.0
|
111
|
-
def +(vector2)
|
112
|
-
end
|
113
|
-
|
114
|
-
# The - method is used to subtract a vector from this one.
|
115
|
-
#
|
116
|
-
# @example
|
117
|
-
# vector = Geom::Vector3d.new(0,0,2)
|
118
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
119
|
-
# new_vector = vector - vector2
|
120
|
-
#
|
121
|
-
# @param vector2
|
122
|
-
# A Vector3d object.
|
123
|
-
#
|
124
|
-
# @return [Geom::Vector3d] the new vector.
|
125
|
-
#
|
126
|
-
# @version SketchUp 6.0
|
127
|
-
def -(vector2)
|
128
|
-
end
|
129
|
-
|
130
|
-
# The < method is used to determine if a vector's x, y or z value is less
|
131
|
-
# than another vector's x, y or z value.
|
132
|
-
#
|
133
|
-
# @example
|
134
|
-
# vector = Geom::Vector3d.new(0,0,2)
|
135
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
136
|
-
# lt = vector < vector2
|
137
|
-
#
|
138
|
-
# @param vector2
|
139
|
-
# A Vector3d object.
|
140
|
-
#
|
141
|
-
# @return [Boolean] true if the vector's x, y or z component is less
|
142
|
-
#
|
143
|
-
# @version SketchUp 6.0
|
144
|
-
def <(vector2)
|
145
|
-
end
|
146
|
-
|
147
|
-
# The == method is used to determine if two vectors are equal to within
|
148
|
-
# tolerance.
|
149
|
-
#
|
150
|
-
# @example
|
151
|
-
# vector = Geom::Vector3d.new(1,0,0)
|
152
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
153
|
-
# status = vector == vector2
|
154
|
-
# # Returns false
|
155
|
-
# UI.messagebox status
|
156
|
-
#
|
157
|
-
# @param vector2
|
158
|
-
# A Vector3d object.
|
159
|
-
#
|
160
|
-
# @return [Boolean]
|
161
|
-
#
|
162
|
-
# @version SketchUp 6.0
|
163
|
-
def ==(vector2)
|
164
|
-
end
|
165
|
-
|
166
|
-
# The [] method is used to access the coordinates of a vector as if it was an
|
167
|
-
# Array. The index must be 0, 1 or 2.
|
168
|
-
#
|
169
|
-
# The following are equivalent:
|
170
|
-
#
|
171
|
-
# @example
|
172
|
-
# x = vector.x
|
173
|
-
# x = vector[0]
|
174
|
-
#
|
175
|
-
# @example
|
176
|
-
# vector = Geom::Vector3d.new(1,0,0)
|
177
|
-
# value = vector[0]
|
178
|
-
# if (value)
|
179
|
-
# UI.messagebox value
|
180
|
-
# else
|
181
|
-
# UI.messagebox "Failure"
|
182
|
-
# end
|
183
|
-
#
|
184
|
-
# @param [Integer] i
|
185
|
-
# An index into an array of three coordinates.
|
186
|
-
#
|
187
|
-
# @return [Length] the value for the x, y, or z coordinate.
|
188
|
-
#
|
189
|
-
# @version SketchUp 6.0
|
190
|
-
def [](i)
|
191
|
-
end
|
192
|
-
|
193
|
-
# The []= method is used to set the coordinates of a vector as if it was an
|
194
|
-
# Array. The value of i must be 0, 1 or 2.
|
195
|
-
#
|
196
|
-
# @example
|
197
|
-
# vector[i] = coordinate
|
198
|
-
#
|
199
|
-
# @param [Integer] index
|
200
|
-
# The index for the x, y, or z coordinate.
|
201
|
-
#
|
202
|
-
# @param [Numeric] value
|
203
|
-
# The value for the x, y, or z coordinate.
|
204
|
-
#
|
205
|
-
# @return [Numeric] the newly set coordinate value
|
206
|
-
#
|
207
|
-
# @version SketchUp 6.0
|
208
|
-
def []=(index, value)
|
209
|
-
end
|
210
|
-
|
211
|
-
# The angle_between method is used to compute the angle (in radians) between
|
212
|
-
# this vector and another vector.
|
213
|
-
#
|
214
|
-
# @example
|
215
|
-
# vector1 = Geom::Vector3d.new(1,0,0)
|
216
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
217
|
-
# angle = vector1.angle_between vector2
|
218
|
-
#
|
219
|
-
# @param [Geom::Vector3d] vector2
|
220
|
-
# A Vector3d object.
|
221
|
-
#
|
222
|
-
# @return [Float] an angle (in radians)
|
223
|
-
#
|
224
|
-
# @version SketchUp 6.0
|
225
|
-
def angle_between(vector2)
|
226
|
-
end
|
227
|
-
|
228
|
-
# The axes method is used to compute an arbitrary set of axes with the given
|
229
|
-
# vector as the z-axis direction.
|
230
|
-
#
|
231
|
-
# Returns an Array of three vectors [xaxis, yaxis, zaxis]
|
232
|
-
#
|
233
|
-
# @example
|
234
|
-
# vector = Geom::Vector3d.new(1,0,0)
|
235
|
-
# a = vector.axes
|
236
|
-
#
|
237
|
-
# @return [Array(Geom::Vector3d, Geom::Vector3d, Geom::Vector3d)] an Array object containing three Vector3d objects
|
238
|
-
#
|
239
|
-
# @version SketchUp 6.0
|
240
|
-
def axes
|
241
|
-
end
|
242
|
-
|
243
|
-
# The clone method is used to make a copy of a vector.
|
244
|
-
#
|
245
|
-
# This method is equivalent to vec2 = Geom::Vector3d.new(vec)
|
246
|
-
#
|
247
|
-
# @example
|
248
|
-
# vector = Geom::Vector3d.new(1,0,0)
|
249
|
-
# vector2 = vector.clone
|
250
|
-
#
|
251
|
-
# @return [Geom::Vector3d] a Vector3d object which is the clone of
|
252
|
-
# vector
|
253
|
-
#
|
254
|
-
# @version SketchUp 6.0
|
255
|
-
def clone
|
256
|
-
end
|
257
|
-
|
258
|
-
# The {#cross} method is used to compute the cross product between two vectors.
|
259
|
-
#
|
260
|
-
# The cross product, also called the vector product, is an operation on two
|
261
|
-
# vectors. The cross product of two vectors produces a third vector which is
|
262
|
-
# perpendicular to the plane in which the first two lie.
|
263
|
-
#
|
264
|
-
# @example
|
265
|
-
# vector1 = Geom::Vector3d.new(1,0,0)
|
266
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
267
|
-
# vector3 = vector1 * vector2
|
268
|
-
#
|
269
|
-
# @example
|
270
|
-
# vector = Geom::Vector3d.new(1,0,0)
|
271
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
272
|
-
# vector3 = vector.cross(vector2)
|
273
|
-
#
|
274
|
-
# @param [Geom::Vector3d] vector
|
275
|
-
# A Vector3d object.
|
276
|
-
#
|
277
|
-
# @return [Geom::Vector3d] the cross of vector1 and vector2
|
278
|
-
#
|
279
|
-
# @see #*
|
280
|
-
#
|
281
|
-
# @version SketchUp 6.0
|
282
|
-
def cross(vector)
|
283
|
-
end
|
284
|
-
|
285
|
-
# The {#dot} method is used to compute the dot product between two vectors.
|
286
|
-
#
|
287
|
-
# @example
|
288
|
-
# vector1 = Geom::Vector3d.new(0, 0, 1)
|
289
|
-
# vector2 = Geom::Vector3d.new(0, 1, 0)
|
290
|
-
# dot = vector1.dot(vector2)
|
291
|
-
#
|
292
|
-
# @param [Geom::Vector] vector
|
293
|
-
#
|
294
|
-
# @return [Float]
|
295
|
-
#
|
296
|
-
# @see #%
|
297
|
-
#
|
298
|
-
# @version SketchUp 6.0
|
299
|
-
def dot(vector)
|
300
|
-
end
|
301
|
-
|
302
|
-
# The new method is used to create a new vector.
|
303
|
-
#
|
304
|
-
# @example
|
305
|
-
# # A vector that runs up the Z axis.
|
306
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
307
|
-
# if (vector)
|
308
|
-
# UI.messagebox vector
|
309
|
-
# else
|
310
|
-
# UI.messagebox "Failure"
|
311
|
-
# end
|
312
|
-
#
|
313
|
-
# @overload initialize
|
314
|
-
#
|
315
|
-
# @return [Geom::Vector3d]
|
316
|
-
#
|
317
|
-
# @overload initialize(x, y, z)
|
318
|
-
#
|
319
|
-
# @param [Numeric] x
|
320
|
-
# @param [Numeric] y
|
321
|
-
# @param [Numeric] z
|
322
|
-
# @return [Geom::Vector3d]
|
323
|
-
#
|
324
|
-
# @overload initialize(array3d)
|
325
|
-
#
|
326
|
-
# @param [Array(Numeric, Numeric, Numeric)] array3d
|
327
|
-
# @return [Geom::Vector3d]
|
328
|
-
#
|
329
|
-
# @overload initialize(array2d)
|
330
|
-
#
|
331
|
-
# @param [Array(Numeric, Numeric)] array2d
|
332
|
-
# @return [Geom::Vector3d]
|
333
|
-
#
|
334
|
-
# @overload initialize(vector)
|
335
|
-
#
|
336
|
-
# @param vector [Geom::Vector3d] A Vector3d object.
|
337
|
-
# @return [Geom::Vector3d]
|
338
|
-
#
|
339
|
-
# @version SketchUp 6.0
|
340
|
-
def initialize(*args)
|
341
|
-
end
|
342
|
-
|
343
|
-
# The inspect method is used to inspect the contents of a vector as a
|
344
|
-
# friendly string.
|
345
|
-
#
|
346
|
-
# @example
|
347
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
348
|
-
# out_string = vector.inspect
|
349
|
-
# puts out_string
|
350
|
-
#
|
351
|
-
# @return [Geom::Vector3d] the Vector3d object
|
352
|
-
#
|
353
|
-
# @version SketchUp 6.0
|
354
|
-
def inspect
|
355
|
-
end
|
356
|
-
|
357
|
-
# The length method is used to retrieve the length of the vector.
|
358
|
-
#
|
359
|
-
# @example
|
360
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
361
|
-
# l = vector.length
|
362
|
-
#
|
363
|
-
# @return [Length] the length of the vector
|
364
|
-
#
|
365
|
-
# @version SketchUp 6.0
|
366
|
-
def length
|
367
|
-
end
|
368
|
-
|
369
|
-
# The length= method is used to set the length of the vector. The length must
|
370
|
-
# be greater than 0.
|
371
|
-
#
|
372
|
-
# @example
|
373
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
374
|
-
# l = vector.length
|
375
|
-
# UI.messagebox(l)
|
376
|
-
# newl = vector.length = 2
|
377
|
-
#
|
378
|
-
# @param [Numeric] length
|
379
|
-
# A length for the vector.
|
380
|
-
#
|
381
|
-
# @return [Numeric] a newly set length
|
382
|
-
#
|
383
|
-
# @version SketchUp 6.0
|
384
|
-
def length=(length)
|
385
|
-
end
|
386
|
-
|
387
|
-
# The normalize method is used to return a vector that is a unit vector
|
388
|
-
# of another.
|
389
|
-
#
|
390
|
-
# @example
|
391
|
-
# vector = Geom::Vector3d.new(0,0,2)
|
392
|
-
# vector2 = vector.normalize
|
393
|
-
#
|
394
|
-
# @return [Geom::Vector3d] a new normalized Vector3d object
|
395
|
-
#
|
396
|
-
# @version SketchUp 6.0
|
397
|
-
def normalize
|
398
|
-
end
|
399
|
-
|
400
|
-
# The normalize! method is used to convert a vector into a unit vector,
|
401
|
-
# in place.
|
402
|
-
#
|
403
|
-
# Another way to do this is vec.length = 1
|
404
|
-
#
|
405
|
-
# @example
|
406
|
-
# vector = Geom::Vector3d.new(0,0,2)
|
407
|
-
# vector.normalize!
|
408
|
-
#
|
409
|
-
# @return [Geom::Vector3d] a normalized Vector3d object
|
410
|
-
#
|
411
|
-
# @version SketchUp 6.0
|
412
|
-
def normalize!
|
413
|
-
end
|
414
|
-
|
415
|
-
# The parallel method is used to determine if this vector is parallel to
|
416
|
-
# another vector to within tolerance.
|
417
|
-
#
|
418
|
-
# @example
|
419
|
-
# status = vector.parallel?(vector2)
|
420
|
-
#
|
421
|
-
# @param [Geom::Vector3d] vector2
|
422
|
-
# A Vector3d object.
|
423
|
-
#
|
424
|
-
# @return [Boolean]
|
425
|
-
#
|
426
|
-
# @version SketchUp 6.0
|
427
|
-
def parallel?(vector2)
|
428
|
-
end
|
429
|
-
|
430
|
-
# The perpendicular? method is used to determine if this vector is
|
431
|
-
# perpendicular to another vector to within tolerance.
|
432
|
-
#
|
433
|
-
# @example
|
434
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
435
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
436
|
-
# status = vector.perpendicular?(vector2)
|
437
|
-
#
|
438
|
-
# @param [Geom::Vector3d] vector2
|
439
|
-
# A Vector3d object.
|
440
|
-
#
|
441
|
-
# @return [Boolean]
|
442
|
-
#
|
443
|
-
# @version SketchUp 6.0
|
444
|
-
def perpendicular?(vector2)
|
445
|
-
end
|
446
|
-
|
447
|
-
# The reverse method is used to return a new vector that is the reverse
|
448
|
-
# of this vector, while leaving the original unchanged.
|
449
|
-
#
|
450
|
-
# @example
|
451
|
-
# vector2 = vector.reverse
|
452
|
-
#
|
453
|
-
# @return [Geom::Vector3d] a Vector3d object that is the reverse of
|
454
|
-
# vector
|
455
|
-
#
|
456
|
-
# @version SketchUp 6.0
|
457
|
-
def reverse
|
458
|
-
end
|
459
|
-
|
460
|
-
# The reverse! method is used to reverse the vector in place.
|
461
|
-
#
|
462
|
-
# @example
|
463
|
-
# vector.reverse!
|
464
|
-
#
|
465
|
-
# @return [Geom::Vector3d] a Vector3d object that is the reverse of
|
466
|
-
# vector
|
467
|
-
#
|
468
|
-
# @version SketchUp 6.0
|
469
|
-
def reverse!
|
470
|
-
end
|
471
|
-
|
472
|
-
# The samedirection? method is used to determine if this vector is parallel to
|
473
|
-
# and in the same direction as another vector to within tolerance.
|
474
|
-
#
|
475
|
-
# @example
|
476
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
477
|
-
# vector2 = Geom::Vector3d.new(0,1,0)
|
478
|
-
# status = vector.samedirection?(vector2)
|
479
|
-
#
|
480
|
-
# @param [Geom::Vector3d] vector2
|
481
|
-
# A Vector3d object.
|
482
|
-
#
|
483
|
-
# @return [Boolean]
|
484
|
-
#
|
485
|
-
# @version SketchUp 6.0
|
486
|
-
def samedirection?(vector2)
|
487
|
-
end
|
488
|
-
|
489
|
-
# The set! method is used to set the coordinates of the vector.
|
490
|
-
#
|
491
|
-
# @example This is a shortcut for writing:
|
492
|
-
# vec.x = x
|
493
|
-
# vec.y = y
|
494
|
-
# vec.z = z
|
495
|
-
#
|
496
|
-
# @example You may also call this method with an array or another vector:
|
497
|
-
# vec.set!(x, y, z)
|
498
|
-
# vec.set!([x, y, z])
|
499
|
-
# vec.set!(vec2)
|
500
|
-
#
|
501
|
-
# @example
|
502
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
503
|
-
# vector.set! 1,0,0
|
504
|
-
#
|
505
|
-
# @overload set!(array3d)
|
506
|
-
#
|
507
|
-
# @param array3d [Array(Numeric, Numeric, Numeric)]
|
508
|
-
# @return [Geom::Vector3d]
|
509
|
-
#
|
510
|
-
# @overload set!(vector)
|
511
|
-
#
|
512
|
-
# @param vector [Geom::Vector3d]
|
513
|
-
# @return [Geom::Vector3d]
|
514
|
-
#
|
515
|
-
# @overload set!(x, y, z)
|
516
|
-
#
|
517
|
-
# @param [Numeric] x
|
518
|
-
# @param [Numeric] y
|
519
|
-
# @param [Numeric] z
|
520
|
-
# @return [Geom::Vector3d]
|
521
|
-
#
|
522
|
-
# @version SketchUp 6.0
|
523
|
-
def set!(*args)
|
524
|
-
end
|
525
|
-
|
526
|
-
# The to_a method retrieves the coordinates of the vector in an Array
|
527
|
-
# [x, y, z].
|
528
|
-
#
|
529
|
-
# @example
|
530
|
-
# a = vector.to_a
|
531
|
-
#
|
532
|
-
# @return [Array(Length, Length, Length)] the coordinates of the vector in an array
|
533
|
-
#
|
534
|
-
# @version SketchUp 6.0
|
535
|
-
def to_a
|
536
|
-
end
|
537
|
-
|
538
|
-
# The to_s method is used to format the vector as a String.
|
539
|
-
#
|
540
|
-
# @example
|
541
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
542
|
-
# out_string = vector.to_s
|
543
|
-
# puts out_string
|
544
|
-
#
|
545
|
-
# @return [String] a string representation of vector
|
546
|
-
#
|
547
|
-
# @version SketchUp 6.0
|
548
|
-
def to_s
|
549
|
-
end
|
550
|
-
|
551
|
-
# Apply a Transformation to a vector, returning a new vector. The original
|
552
|
-
# vector is unchanged by this method.
|
553
|
-
#
|
554
|
-
# @example
|
555
|
-
# vector2 = vector.transform(transformation)
|
556
|
-
#
|
557
|
-
# @param [Geom::Transformation] transform
|
558
|
-
# A Transformation object to apply to the vector.
|
559
|
-
#
|
560
|
-
# @return [Geom::Vector3d] the newly transformed vector
|
561
|
-
#
|
562
|
-
# @version SketchUp 6.0
|
563
|
-
def transform(transform)
|
564
|
-
end
|
565
|
-
|
566
|
-
# Apply a Transformation to a vector. The vector itself is modified.
|
567
|
-
#
|
568
|
-
# @example
|
569
|
-
# vector.transform!(transformation)
|
570
|
-
#
|
571
|
-
# @param [Geom::Transformation] transform
|
572
|
-
# A Transformation object to apply to the vector.
|
573
|
-
#
|
574
|
-
# @return [Geom::Vector3d] the transformed vector
|
575
|
-
#
|
576
|
-
# @version SketchUp 6.0
|
577
|
-
def transform!(transform)
|
578
|
-
end
|
579
|
-
|
580
|
-
# The unitvector? method is used to see if the vector is a unit vector.
|
581
|
-
#
|
582
|
-
# This is equivalent to vec.length == 1.0
|
583
|
-
#
|
584
|
-
# @example
|
585
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
586
|
-
# status = vector.unitvector?
|
587
|
-
#
|
588
|
-
# @return [Boolean]
|
589
|
-
#
|
590
|
-
# @version SketchUp 6.0
|
591
|
-
def unitvector?
|
592
|
-
end
|
593
|
-
|
594
|
-
# The valid? method is used to verify if a vector is valid. A vector is valid
|
595
|
-
# if its length is not zero.
|
596
|
-
#
|
597
|
-
# @example
|
598
|
-
# # A zero length vector will be invalid
|
599
|
-
# vector = Geom::Vector3d.new(0,0,0)
|
600
|
-
# status = vector.valid?
|
601
|
-
# # A non-zero length vector is valid
|
602
|
-
# vector = Geom::Vector3d.new(0,0,1)
|
603
|
-
# status = vector.valid?
|
604
|
-
#
|
605
|
-
# @return [Boolean]
|
606
|
-
#
|
607
|
-
# @version SketchUp 6.0
|
608
|
-
def valid?
|
609
|
-
end
|
610
|
-
|
611
|
-
# The x method is used to retrieve the x coordinate of the vector.
|
612
|
-
#
|
613
|
-
# @example
|
614
|
-
# x = vector.x
|
615
|
-
#
|
616
|
-
# @return [Length] the x coordinate of the vector
|
617
|
-
#
|
618
|
-
# @version SketchUp 6.0
|
619
|
-
def x
|
620
|
-
end
|
621
|
-
|
622
|
-
# The x= method is used to set the x coordinate of the vector.
|
623
|
-
#
|
624
|
-
# @example
|
625
|
-
# vector = Geom::Vector3d.new 1,2,3
|
626
|
-
# x = vector.x = 10
|
627
|
-
#
|
628
|
-
# @param [Numeric] x
|
629
|
-
# The x coordinate for the vector.
|
630
|
-
#
|
631
|
-
# @return [Numeric] the newly set x coordinate for the vector
|
632
|
-
#
|
633
|
-
# @version SketchUp 6.0
|
634
|
-
def x=(x)
|
635
|
-
end
|
636
|
-
|
637
|
-
# The y method is used to retrieve the y coordinate of the vector.
|
638
|
-
#
|
639
|
-
# @example
|
640
|
-
# vector = Geom::Vector3d.new(1,2,3)
|
641
|
-
# y = vector.y
|
642
|
-
#
|
643
|
-
# @return [Length] the y coordinate of the vector
|
644
|
-
#
|
645
|
-
# @version SketchUp 6.0
|
646
|
-
def y
|
647
|
-
end
|
648
|
-
|
649
|
-
# Set the y coordinate of the vector.
|
650
|
-
#
|
651
|
-
# @example
|
652
|
-
# vector = Geom::Vector3d.new(1,2,3)
|
653
|
-
# y = vector.y = 10
|
654
|
-
#
|
655
|
-
# @param [Numeric] y
|
656
|
-
# The y coordinate for the vector.
|
657
|
-
#
|
658
|
-
# @return [Numeric] the newly set y coordinate for the vector
|
659
|
-
#
|
660
|
-
# @version SketchUp 6.0
|
661
|
-
def y=(y)
|
662
|
-
end
|
663
|
-
|
664
|
-
# Get the z coordinate of the vector.
|
665
|
-
#
|
666
|
-
# @example
|
667
|
-
# vector = Geom::Vector3d.new(1,2,3)
|
668
|
-
# z = vector.z
|
669
|
-
#
|
670
|
-
# @return [Length] the z coordinate of the vector
|
671
|
-
#
|
672
|
-
# @version SketchUp 6.0
|
673
|
-
def z
|
674
|
-
end
|
675
|
-
|
676
|
-
# Set the z coordinate of the vector.
|
677
|
-
#
|
678
|
-
# @example
|
679
|
-
# vector = Geom::Vector3d.new(1,2,3)
|
680
|
-
# z = vector.z = 10
|
681
|
-
#
|
682
|
-
# @param [Numeric] z
|
683
|
-
# The z coordinate for the vector.
|
684
|
-
#
|
685
|
-
# @return [Numeric] the newly set z coordinate for the vector
|
686
|
-
#
|
687
|
-
# @version SketchUp 6.0
|
688
|
-
def z=(z)
|
689
|
-
end
|
690
|
-
|
691
|
-
end
|
1
|
+
# Copyright:: Copyright 2020 Trimble Inc.
|
2
|
+
# License:: The MIT License (MIT)
|
3
|
+
|
4
|
+
# The Vector3d class is used to represent vectors in a 3 dimensional space.
|
5
|
+
# Vectors in SketchUp have a direction and a length, but not a starting point.
|
6
|
+
#
|
7
|
+
# There are numerous tutorials on 3D vectors available on the internet.
|
8
|
+
#
|
9
|
+
# @version SketchUp 6.0
|
10
|
+
class Geom::Vector3d
|
11
|
+
|
12
|
+
# Class Methods
|
13
|
+
|
14
|
+
# The {.linear_combination} method is used to create a new vector as a linear
|
15
|
+
# combination of other vectors. This method is generally used to get a vector
|
16
|
+
# at some percentage between two vectors.
|
17
|
+
#
|
18
|
+
# A linear combination is a standard term for vector math. It is defined as
|
19
|
+
# vector = weight1 * vector1 + weight2 * vector2.
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# # Create a vector that is a 50%/50% linear combination of two others.
|
23
|
+
# vec1 = Geom::Vector3d.new 3,0,0
|
24
|
+
# vec2 = Geom::Vector3d.new 0,3,0
|
25
|
+
# new_vector = Geom::Vector3d.linear_combination(0.5, vec1, 0.5, vec2)
|
26
|
+
# # new_vector will now contain a Vector3d(1.5, 1.5, 0)
|
27
|
+
#
|
28
|
+
# @overload linear_combination(weight1, vector1, weight2, vector2)
|
29
|
+
#
|
30
|
+
# @param [Numeric] weight1 A weight or percentage.
|
31
|
+
# @param [Geom::Vector3d] vector1 The first vector.
|
32
|
+
# @param [Numeric] weight2 A weight or percentage.
|
33
|
+
# @param [Geom::Vector3d] vector2 The second vector.
|
34
|
+
# @return [Geom::Vector3d]
|
35
|
+
#
|
36
|
+
# @overload linear_combination(x, xaxis, y, yaxis, z, zaxis)
|
37
|
+
#
|
38
|
+
# @param [Numeric] x A weight or percentage for the x axis.
|
39
|
+
# @param [Geom::Vector3d] xaxis The x axis vector.
|
40
|
+
# @param [Numeric] y A weight or percentage for the y axis.
|
41
|
+
# @param [Geom::Vector3d] yaxis The y axis vector.
|
42
|
+
# @param [Numeric] z A weight or percentage for the z axis.
|
43
|
+
# @param [Geom::Vector3d] zaxis The z axis vector.
|
44
|
+
# @return [Geom::Vector3d]
|
45
|
+
#
|
46
|
+
# @version SketchUp 6.0
|
47
|
+
def self.linear_combination(*args)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Instance Methods
|
51
|
+
|
52
|
+
# The {#%} method is used to compute the dot product between two vectors.
|
53
|
+
#
|
54
|
+
# This is an alias of the {#dot} method.
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# vector1 = Geom::Vector3d.new(0, 0, 1)
|
58
|
+
# vector2 = Geom::Vector3d.new(0, 1, 0)
|
59
|
+
# dot = vector1 % vector2
|
60
|
+
#
|
61
|
+
# @param [Geom::Vector] vector
|
62
|
+
#
|
63
|
+
# @return [Float]
|
64
|
+
#
|
65
|
+
# @see #dot
|
66
|
+
#
|
67
|
+
# @version SketchUp 6.0
|
68
|
+
def %(vector)
|
69
|
+
end
|
70
|
+
|
71
|
+
# The {#cross} method is used to compute the cross product between two vectors.
|
72
|
+
#
|
73
|
+
# The cross product, also called the vector product, is an operation on two
|
74
|
+
# vectors. The cross product of two vectors produces a third vector which is
|
75
|
+
# perpendicular to the plane in which the first two lie.
|
76
|
+
#
|
77
|
+
# @example
|
78
|
+
# vector1 = Geom::Vector3d.new(1,0,0)
|
79
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
80
|
+
# vector3 = vector1 * vector2
|
81
|
+
#
|
82
|
+
# @example
|
83
|
+
# vector = Geom::Vector3d.new(1,0,0)
|
84
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
85
|
+
# vector3 = vector.cross(vector2)
|
86
|
+
#
|
87
|
+
# @param [Geom::Vector3d] vector
|
88
|
+
# A Vector3d object.
|
89
|
+
#
|
90
|
+
# @return [Geom::Vector3d] the cross of vector1 and vector2
|
91
|
+
#
|
92
|
+
# @see #*
|
93
|
+
#
|
94
|
+
# @version SketchUp 6.0
|
95
|
+
def *(vector)
|
96
|
+
end
|
97
|
+
|
98
|
+
# The - method is used to add a vector to this one.
|
99
|
+
#
|
100
|
+
# @example
|
101
|
+
# vector = Geom::Vector3d.new(0,0,2)
|
102
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
103
|
+
# new_vector = vector + vector2
|
104
|
+
#
|
105
|
+
# @param vector2
|
106
|
+
# A Vector3d object.
|
107
|
+
#
|
108
|
+
# @return [Geom::Vector3d] the new vector.
|
109
|
+
#
|
110
|
+
# @version SketchUp 6.0
|
111
|
+
def +(vector2)
|
112
|
+
end
|
113
|
+
|
114
|
+
# The - method is used to subtract a vector from this one.
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# vector = Geom::Vector3d.new(0,0,2)
|
118
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
119
|
+
# new_vector = vector - vector2
|
120
|
+
#
|
121
|
+
# @param vector2
|
122
|
+
# A Vector3d object.
|
123
|
+
#
|
124
|
+
# @return [Geom::Vector3d] the new vector.
|
125
|
+
#
|
126
|
+
# @version SketchUp 6.0
|
127
|
+
def -(vector2)
|
128
|
+
end
|
129
|
+
|
130
|
+
# The < method is used to determine if a vector's x, y or z value is less
|
131
|
+
# than another vector's x, y or z value.
|
132
|
+
#
|
133
|
+
# @example
|
134
|
+
# vector = Geom::Vector3d.new(0,0,2)
|
135
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
136
|
+
# lt = vector < vector2
|
137
|
+
#
|
138
|
+
# @param vector2
|
139
|
+
# A Vector3d object.
|
140
|
+
#
|
141
|
+
# @return [Boolean] true if the vector's x, y or z component is less
|
142
|
+
#
|
143
|
+
# @version SketchUp 6.0
|
144
|
+
def <(vector2)
|
145
|
+
end
|
146
|
+
|
147
|
+
# The == method is used to determine if two vectors are equal to within
|
148
|
+
# tolerance.
|
149
|
+
#
|
150
|
+
# @example
|
151
|
+
# vector = Geom::Vector3d.new(1,0,0)
|
152
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
153
|
+
# status = vector == vector2
|
154
|
+
# # Returns false
|
155
|
+
# UI.messagebox status
|
156
|
+
#
|
157
|
+
# @param vector2
|
158
|
+
# A Vector3d object.
|
159
|
+
#
|
160
|
+
# @return [Boolean]
|
161
|
+
#
|
162
|
+
# @version SketchUp 6.0
|
163
|
+
def ==(vector2)
|
164
|
+
end
|
165
|
+
|
166
|
+
# The [] method is used to access the coordinates of a vector as if it was an
|
167
|
+
# Array. The index must be 0, 1 or 2.
|
168
|
+
#
|
169
|
+
# The following are equivalent:
|
170
|
+
#
|
171
|
+
# @example
|
172
|
+
# x = vector.x
|
173
|
+
# x = vector[0]
|
174
|
+
#
|
175
|
+
# @example
|
176
|
+
# vector = Geom::Vector3d.new(1,0,0)
|
177
|
+
# value = vector[0]
|
178
|
+
# if (value)
|
179
|
+
# UI.messagebox value
|
180
|
+
# else
|
181
|
+
# UI.messagebox "Failure"
|
182
|
+
# end
|
183
|
+
#
|
184
|
+
# @param [Integer] i
|
185
|
+
# An index into an array of three coordinates.
|
186
|
+
#
|
187
|
+
# @return [Length] the value for the x, y, or z coordinate.
|
188
|
+
#
|
189
|
+
# @version SketchUp 6.0
|
190
|
+
def [](i)
|
191
|
+
end
|
192
|
+
|
193
|
+
# The []= method is used to set the coordinates of a vector as if it was an
|
194
|
+
# Array. The value of i must be 0, 1 or 2.
|
195
|
+
#
|
196
|
+
# @example
|
197
|
+
# vector[i] = coordinate
|
198
|
+
#
|
199
|
+
# @param [Integer] index
|
200
|
+
# The index for the x, y, or z coordinate.
|
201
|
+
#
|
202
|
+
# @param [Numeric] value
|
203
|
+
# The value for the x, y, or z coordinate.
|
204
|
+
#
|
205
|
+
# @return [Numeric] the newly set coordinate value
|
206
|
+
#
|
207
|
+
# @version SketchUp 6.0
|
208
|
+
def []=(index, value)
|
209
|
+
end
|
210
|
+
|
211
|
+
# The angle_between method is used to compute the angle (in radians) between
|
212
|
+
# this vector and another vector.
|
213
|
+
#
|
214
|
+
# @example
|
215
|
+
# vector1 = Geom::Vector3d.new(1,0,0)
|
216
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
217
|
+
# angle = vector1.angle_between vector2
|
218
|
+
#
|
219
|
+
# @param [Geom::Vector3d] vector2
|
220
|
+
# A Vector3d object.
|
221
|
+
#
|
222
|
+
# @return [Float] an angle (in radians)
|
223
|
+
#
|
224
|
+
# @version SketchUp 6.0
|
225
|
+
def angle_between(vector2)
|
226
|
+
end
|
227
|
+
|
228
|
+
# The axes method is used to compute an arbitrary set of axes with the given
|
229
|
+
# vector as the z-axis direction.
|
230
|
+
#
|
231
|
+
# Returns an Array of three vectors [xaxis, yaxis, zaxis]
|
232
|
+
#
|
233
|
+
# @example
|
234
|
+
# vector = Geom::Vector3d.new(1,0,0)
|
235
|
+
# a = vector.axes
|
236
|
+
#
|
237
|
+
# @return [Array(Geom::Vector3d, Geom::Vector3d, Geom::Vector3d)] an Array object containing three Vector3d objects
|
238
|
+
#
|
239
|
+
# @version SketchUp 6.0
|
240
|
+
def axes
|
241
|
+
end
|
242
|
+
|
243
|
+
# The clone method is used to make a copy of a vector.
|
244
|
+
#
|
245
|
+
# This method is equivalent to vec2 = Geom::Vector3d.new(vec)
|
246
|
+
#
|
247
|
+
# @example
|
248
|
+
# vector = Geom::Vector3d.new(1,0,0)
|
249
|
+
# vector2 = vector.clone
|
250
|
+
#
|
251
|
+
# @return [Geom::Vector3d] a Vector3d object which is the clone of
|
252
|
+
# vector
|
253
|
+
#
|
254
|
+
# @version SketchUp 6.0
|
255
|
+
def clone
|
256
|
+
end
|
257
|
+
|
258
|
+
# The {#cross} method is used to compute the cross product between two vectors.
|
259
|
+
#
|
260
|
+
# The cross product, also called the vector product, is an operation on two
|
261
|
+
# vectors. The cross product of two vectors produces a third vector which is
|
262
|
+
# perpendicular to the plane in which the first two lie.
|
263
|
+
#
|
264
|
+
# @example
|
265
|
+
# vector1 = Geom::Vector3d.new(1,0,0)
|
266
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
267
|
+
# vector3 = vector1 * vector2
|
268
|
+
#
|
269
|
+
# @example
|
270
|
+
# vector = Geom::Vector3d.new(1,0,0)
|
271
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
272
|
+
# vector3 = vector.cross(vector2)
|
273
|
+
#
|
274
|
+
# @param [Geom::Vector3d] vector
|
275
|
+
# A Vector3d object.
|
276
|
+
#
|
277
|
+
# @return [Geom::Vector3d] the cross of vector1 and vector2
|
278
|
+
#
|
279
|
+
# @see #*
|
280
|
+
#
|
281
|
+
# @version SketchUp 6.0
|
282
|
+
def cross(vector)
|
283
|
+
end
|
284
|
+
|
285
|
+
# The {#dot} method is used to compute the dot product between two vectors.
|
286
|
+
#
|
287
|
+
# @example
|
288
|
+
# vector1 = Geom::Vector3d.new(0, 0, 1)
|
289
|
+
# vector2 = Geom::Vector3d.new(0, 1, 0)
|
290
|
+
# dot = vector1.dot(vector2)
|
291
|
+
#
|
292
|
+
# @param [Geom::Vector] vector
|
293
|
+
#
|
294
|
+
# @return [Float]
|
295
|
+
#
|
296
|
+
# @see #%
|
297
|
+
#
|
298
|
+
# @version SketchUp 6.0
|
299
|
+
def dot(vector)
|
300
|
+
end
|
301
|
+
|
302
|
+
# The new method is used to create a new vector.
|
303
|
+
#
|
304
|
+
# @example
|
305
|
+
# # A vector that runs up the Z axis.
|
306
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
307
|
+
# if (vector)
|
308
|
+
# UI.messagebox vector
|
309
|
+
# else
|
310
|
+
# UI.messagebox "Failure"
|
311
|
+
# end
|
312
|
+
#
|
313
|
+
# @overload initialize
|
314
|
+
#
|
315
|
+
# @return [Geom::Vector3d]
|
316
|
+
#
|
317
|
+
# @overload initialize(x, y, z)
|
318
|
+
#
|
319
|
+
# @param [Numeric] x
|
320
|
+
# @param [Numeric] y
|
321
|
+
# @param [Numeric] z
|
322
|
+
# @return [Geom::Vector3d]
|
323
|
+
#
|
324
|
+
# @overload initialize(array3d)
|
325
|
+
#
|
326
|
+
# @param [Array(Numeric, Numeric, Numeric)] array3d
|
327
|
+
# @return [Geom::Vector3d]
|
328
|
+
#
|
329
|
+
# @overload initialize(array2d)
|
330
|
+
#
|
331
|
+
# @param [Array(Numeric, Numeric)] array2d
|
332
|
+
# @return [Geom::Vector3d]
|
333
|
+
#
|
334
|
+
# @overload initialize(vector)
|
335
|
+
#
|
336
|
+
# @param vector [Geom::Vector3d] A Vector3d object.
|
337
|
+
# @return [Geom::Vector3d]
|
338
|
+
#
|
339
|
+
# @version SketchUp 6.0
|
340
|
+
def initialize(*args)
|
341
|
+
end
|
342
|
+
|
343
|
+
# The inspect method is used to inspect the contents of a vector as a
|
344
|
+
# friendly string.
|
345
|
+
#
|
346
|
+
# @example
|
347
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
348
|
+
# out_string = vector.inspect
|
349
|
+
# puts out_string
|
350
|
+
#
|
351
|
+
# @return [Geom::Vector3d] the Vector3d object
|
352
|
+
#
|
353
|
+
# @version SketchUp 6.0
|
354
|
+
def inspect
|
355
|
+
end
|
356
|
+
|
357
|
+
# The length method is used to retrieve the length of the vector.
|
358
|
+
#
|
359
|
+
# @example
|
360
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
361
|
+
# l = vector.length
|
362
|
+
#
|
363
|
+
# @return [Length] the length of the vector
|
364
|
+
#
|
365
|
+
# @version SketchUp 6.0
|
366
|
+
def length
|
367
|
+
end
|
368
|
+
|
369
|
+
# The length= method is used to set the length of the vector. The length must
|
370
|
+
# be greater than 0.
|
371
|
+
#
|
372
|
+
# @example
|
373
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
374
|
+
# l = vector.length
|
375
|
+
# UI.messagebox(l)
|
376
|
+
# newl = vector.length = 2
|
377
|
+
#
|
378
|
+
# @param [Numeric] length
|
379
|
+
# A length for the vector.
|
380
|
+
#
|
381
|
+
# @return [Numeric] a newly set length
|
382
|
+
#
|
383
|
+
# @version SketchUp 6.0
|
384
|
+
def length=(length)
|
385
|
+
end
|
386
|
+
|
387
|
+
# The normalize method is used to return a vector that is a unit vector
|
388
|
+
# of another.
|
389
|
+
#
|
390
|
+
# @example
|
391
|
+
# vector = Geom::Vector3d.new(0,0,2)
|
392
|
+
# vector2 = vector.normalize
|
393
|
+
#
|
394
|
+
# @return [Geom::Vector3d] a new normalized Vector3d object
|
395
|
+
#
|
396
|
+
# @version SketchUp 6.0
|
397
|
+
def normalize
|
398
|
+
end
|
399
|
+
|
400
|
+
# The normalize! method is used to convert a vector into a unit vector,
|
401
|
+
# in place.
|
402
|
+
#
|
403
|
+
# Another way to do this is vec.length = 1
|
404
|
+
#
|
405
|
+
# @example
|
406
|
+
# vector = Geom::Vector3d.new(0,0,2)
|
407
|
+
# vector.normalize!
|
408
|
+
#
|
409
|
+
# @return [Geom::Vector3d] a normalized Vector3d object
|
410
|
+
#
|
411
|
+
# @version SketchUp 6.0
|
412
|
+
def normalize!
|
413
|
+
end
|
414
|
+
|
415
|
+
# The parallel method is used to determine if this vector is parallel to
|
416
|
+
# another vector to within tolerance.
|
417
|
+
#
|
418
|
+
# @example
|
419
|
+
# status = vector.parallel?(vector2)
|
420
|
+
#
|
421
|
+
# @param [Geom::Vector3d] vector2
|
422
|
+
# A Vector3d object.
|
423
|
+
#
|
424
|
+
# @return [Boolean]
|
425
|
+
#
|
426
|
+
# @version SketchUp 6.0
|
427
|
+
def parallel?(vector2)
|
428
|
+
end
|
429
|
+
|
430
|
+
# The perpendicular? method is used to determine if this vector is
|
431
|
+
# perpendicular to another vector to within tolerance.
|
432
|
+
#
|
433
|
+
# @example
|
434
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
435
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
436
|
+
# status = vector.perpendicular?(vector2)
|
437
|
+
#
|
438
|
+
# @param [Geom::Vector3d] vector2
|
439
|
+
# A Vector3d object.
|
440
|
+
#
|
441
|
+
# @return [Boolean]
|
442
|
+
#
|
443
|
+
# @version SketchUp 6.0
|
444
|
+
def perpendicular?(vector2)
|
445
|
+
end
|
446
|
+
|
447
|
+
# The reverse method is used to return a new vector that is the reverse
|
448
|
+
# of this vector, while leaving the original unchanged.
|
449
|
+
#
|
450
|
+
# @example
|
451
|
+
# vector2 = vector.reverse
|
452
|
+
#
|
453
|
+
# @return [Geom::Vector3d] a Vector3d object that is the reverse of
|
454
|
+
# vector
|
455
|
+
#
|
456
|
+
# @version SketchUp 6.0
|
457
|
+
def reverse
|
458
|
+
end
|
459
|
+
|
460
|
+
# The reverse! method is used to reverse the vector in place.
|
461
|
+
#
|
462
|
+
# @example
|
463
|
+
# vector.reverse!
|
464
|
+
#
|
465
|
+
# @return [Geom::Vector3d] a Vector3d object that is the reverse of
|
466
|
+
# vector
|
467
|
+
#
|
468
|
+
# @version SketchUp 6.0
|
469
|
+
def reverse!
|
470
|
+
end
|
471
|
+
|
472
|
+
# The samedirection? method is used to determine if this vector is parallel to
|
473
|
+
# and in the same direction as another vector to within tolerance.
|
474
|
+
#
|
475
|
+
# @example
|
476
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
477
|
+
# vector2 = Geom::Vector3d.new(0,1,0)
|
478
|
+
# status = vector.samedirection?(vector2)
|
479
|
+
#
|
480
|
+
# @param [Geom::Vector3d] vector2
|
481
|
+
# A Vector3d object.
|
482
|
+
#
|
483
|
+
# @return [Boolean]
|
484
|
+
#
|
485
|
+
# @version SketchUp 6.0
|
486
|
+
def samedirection?(vector2)
|
487
|
+
end
|
488
|
+
|
489
|
+
# The set! method is used to set the coordinates of the vector.
|
490
|
+
#
|
491
|
+
# @example This is a shortcut for writing:
|
492
|
+
# vec.x = x
|
493
|
+
# vec.y = y
|
494
|
+
# vec.z = z
|
495
|
+
#
|
496
|
+
# @example You may also call this method with an array or another vector:
|
497
|
+
# vec.set!(x, y, z)
|
498
|
+
# vec.set!([x, y, z])
|
499
|
+
# vec.set!(vec2)
|
500
|
+
#
|
501
|
+
# @example
|
502
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
503
|
+
# vector.set! 1,0,0
|
504
|
+
#
|
505
|
+
# @overload set!(array3d)
|
506
|
+
#
|
507
|
+
# @param array3d [Array(Numeric, Numeric, Numeric)]
|
508
|
+
# @return [Geom::Vector3d]
|
509
|
+
#
|
510
|
+
# @overload set!(vector)
|
511
|
+
#
|
512
|
+
# @param vector [Geom::Vector3d]
|
513
|
+
# @return [Geom::Vector3d]
|
514
|
+
#
|
515
|
+
# @overload set!(x, y, z)
|
516
|
+
#
|
517
|
+
# @param [Numeric] x
|
518
|
+
# @param [Numeric] y
|
519
|
+
# @param [Numeric] z
|
520
|
+
# @return [Geom::Vector3d]
|
521
|
+
#
|
522
|
+
# @version SketchUp 6.0
|
523
|
+
def set!(*args)
|
524
|
+
end
|
525
|
+
|
526
|
+
# The to_a method retrieves the coordinates of the vector in an Array
|
527
|
+
# [x, y, z].
|
528
|
+
#
|
529
|
+
# @example
|
530
|
+
# a = vector.to_a
|
531
|
+
#
|
532
|
+
# @return [Array(Length, Length, Length)] the coordinates of the vector in an array
|
533
|
+
#
|
534
|
+
# @version SketchUp 6.0
|
535
|
+
def to_a
|
536
|
+
end
|
537
|
+
|
538
|
+
# The to_s method is used to format the vector as a String.
|
539
|
+
#
|
540
|
+
# @example
|
541
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
542
|
+
# out_string = vector.to_s
|
543
|
+
# puts out_string
|
544
|
+
#
|
545
|
+
# @return [String] a string representation of vector
|
546
|
+
#
|
547
|
+
# @version SketchUp 6.0
|
548
|
+
def to_s
|
549
|
+
end
|
550
|
+
|
551
|
+
# Apply a Transformation to a vector, returning a new vector. The original
|
552
|
+
# vector is unchanged by this method.
|
553
|
+
#
|
554
|
+
# @example
|
555
|
+
# vector2 = vector.transform(transformation)
|
556
|
+
#
|
557
|
+
# @param [Geom::Transformation] transform
|
558
|
+
# A Transformation object to apply to the vector.
|
559
|
+
#
|
560
|
+
# @return [Geom::Vector3d] the newly transformed vector
|
561
|
+
#
|
562
|
+
# @version SketchUp 6.0
|
563
|
+
def transform(transform)
|
564
|
+
end
|
565
|
+
|
566
|
+
# Apply a Transformation to a vector. The vector itself is modified.
|
567
|
+
#
|
568
|
+
# @example
|
569
|
+
# vector.transform!(transformation)
|
570
|
+
#
|
571
|
+
# @param [Geom::Transformation] transform
|
572
|
+
# A Transformation object to apply to the vector.
|
573
|
+
#
|
574
|
+
# @return [Geom::Vector3d] the transformed vector
|
575
|
+
#
|
576
|
+
# @version SketchUp 6.0
|
577
|
+
def transform!(transform)
|
578
|
+
end
|
579
|
+
|
580
|
+
# The unitvector? method is used to see if the vector is a unit vector.
|
581
|
+
#
|
582
|
+
# This is equivalent to vec.length == 1.0
|
583
|
+
#
|
584
|
+
# @example
|
585
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
586
|
+
# status = vector.unitvector?
|
587
|
+
#
|
588
|
+
# @return [Boolean]
|
589
|
+
#
|
590
|
+
# @version SketchUp 6.0
|
591
|
+
def unitvector?
|
592
|
+
end
|
593
|
+
|
594
|
+
# The valid? method is used to verify if a vector is valid. A vector is valid
|
595
|
+
# if its length is not zero.
|
596
|
+
#
|
597
|
+
# @example
|
598
|
+
# # A zero length vector will be invalid
|
599
|
+
# vector = Geom::Vector3d.new(0,0,0)
|
600
|
+
# status = vector.valid?
|
601
|
+
# # A non-zero length vector is valid
|
602
|
+
# vector = Geom::Vector3d.new(0,0,1)
|
603
|
+
# status = vector.valid?
|
604
|
+
#
|
605
|
+
# @return [Boolean]
|
606
|
+
#
|
607
|
+
# @version SketchUp 6.0
|
608
|
+
def valid?
|
609
|
+
end
|
610
|
+
|
611
|
+
# The x method is used to retrieve the x coordinate of the vector.
|
612
|
+
#
|
613
|
+
# @example
|
614
|
+
# x = vector.x
|
615
|
+
#
|
616
|
+
# @return [Length] the x coordinate of the vector
|
617
|
+
#
|
618
|
+
# @version SketchUp 6.0
|
619
|
+
def x
|
620
|
+
end
|
621
|
+
|
622
|
+
# The x= method is used to set the x coordinate of the vector.
|
623
|
+
#
|
624
|
+
# @example
|
625
|
+
# vector = Geom::Vector3d.new 1,2,3
|
626
|
+
# x = vector.x = 10
|
627
|
+
#
|
628
|
+
# @param [Numeric] x
|
629
|
+
# The x coordinate for the vector.
|
630
|
+
#
|
631
|
+
# @return [Numeric] the newly set x coordinate for the vector
|
632
|
+
#
|
633
|
+
# @version SketchUp 6.0
|
634
|
+
def x=(x)
|
635
|
+
end
|
636
|
+
|
637
|
+
# The y method is used to retrieve the y coordinate of the vector.
|
638
|
+
#
|
639
|
+
# @example
|
640
|
+
# vector = Geom::Vector3d.new(1,2,3)
|
641
|
+
# y = vector.y
|
642
|
+
#
|
643
|
+
# @return [Length] the y coordinate of the vector
|
644
|
+
#
|
645
|
+
# @version SketchUp 6.0
|
646
|
+
def y
|
647
|
+
end
|
648
|
+
|
649
|
+
# Set the y coordinate of the vector.
|
650
|
+
#
|
651
|
+
# @example
|
652
|
+
# vector = Geom::Vector3d.new(1,2,3)
|
653
|
+
# y = vector.y = 10
|
654
|
+
#
|
655
|
+
# @param [Numeric] y
|
656
|
+
# The y coordinate for the vector.
|
657
|
+
#
|
658
|
+
# @return [Numeric] the newly set y coordinate for the vector
|
659
|
+
#
|
660
|
+
# @version SketchUp 6.0
|
661
|
+
def y=(y)
|
662
|
+
end
|
663
|
+
|
664
|
+
# Get the z coordinate of the vector.
|
665
|
+
#
|
666
|
+
# @example
|
667
|
+
# vector = Geom::Vector3d.new(1,2,3)
|
668
|
+
# z = vector.z
|
669
|
+
#
|
670
|
+
# @return [Length] the z coordinate of the vector
|
671
|
+
#
|
672
|
+
# @version SketchUp 6.0
|
673
|
+
def z
|
674
|
+
end
|
675
|
+
|
676
|
+
# Set the z coordinate of the vector.
|
677
|
+
#
|
678
|
+
# @example
|
679
|
+
# vector = Geom::Vector3d.new(1,2,3)
|
680
|
+
# z = vector.z = 10
|
681
|
+
#
|
682
|
+
# @param [Numeric] z
|
683
|
+
# The z coordinate for the vector.
|
684
|
+
#
|
685
|
+
# @return [Numeric] the newly set z coordinate for the vector
|
686
|
+
#
|
687
|
+
# @version SketchUp 6.0
|
688
|
+
def z=(z)
|
689
|
+
end
|
690
|
+
|
691
|
+
end
|