Vector3d -> Point3d ?
-
Hi all, another simple question.
I would like to define a point by another point + a vector. However, in my Ruby, pt + vec returns another vec object, rather than a pt. So, is there a simple way to convert this returning vec to pt, cos I guess they all belong to array right? Thanks!
-Max
-
point3D.offset(Vector3D) ? (thank you Didier !! )
-
NICE ! Thank you all!
-
Adding a Vector3d to a Point3d should return a Point3d, however the converse is not true. Are you sure of the types of the objects you are "adding"?
@unknownuser said:
cos I guess they all belong to array right?
No! Point3d's and Vector3d's are distinct classes and not related to Arrays. However, SketchUp does add a few methods of "convenience" to the Array class, so that (in some cases) you can use an Array "as if" it were a Point3d or Vector3d.
pt = Geom;;Point3d.new v = Geom;;Vector3d.new (1, 0,0) pt + v ==> Point3d(1, 0, 0) v + pt ==> Error; #<ArgumentError; (eval);45;in `+'; Cannot convert argument to Sketchup;;Vector3d> v + [1,2,3] ==> Vector3d(2, 2, 3)
In this example, the Array ([ 1, 2, 3] ) is made into a Vector3d before the '+' operation.
-
Thank you Jim!
BTW, how can I change my profile? I have no picture nor description for myself. -
-
That does. I guess I misunderstood '+' from the start. Thanks again.
Advertisement