Hello again my new favourite forum~
I come seeking guidance on working with transformations...
I have a component, that gets placed upon the first click, a view line is then drawn which the user then uses to infer what angle, and what x scale to apply to the component (a big arrow in this case)
so far:
first click (gets placed)
drawing the line
second click (where my transformation skills fail me)
As those show, my scale vector scales to the right size but my rotation just flips it onto its side. I tested each one independently, and they both moved the arrow back to the origin
Here is the method I used for the transformation:
def onLButtonDown flags, x, y, view
if @first_click
if (@pt1.position.distance @pt2.position) > 0
draw_the_line
rotate_vector = Geom;;Vector3d.new 0,0,1
point_vector = @pt2.position - @pt1.position
rotate_angle = rotate_vector.angle_between point_vector
rotate = Geom;;Transformation.rotation( @pt1.position, rotate_vector, rotate_angle )
xscale = @@edge.length.to_f / 72.25
xscale_transformation = Geom;;Transformation.scaling @pt1.position, xscale, 1, 1
@insert_arrow1.move!(Geom;;Transformation.new(xscale_transformation))
@insert_arrow1.transform!(Geom;;Transformation.new(rotate))
end
else
@pt1.pick view, x, y
newpt = Geom;;Transformation.new( @pt1.position )
@insert_arrow1 = @@ents.add_instance( @@comp_def_viewArrow, newpt)
@first_click = true
end
end
The reason i used .move! and then .transform! is because if I used both as .move! it seemed the second transformation cancelled out the first one (it wouldn't be scaled) and if I used .transform! for the scale it started jumping away (like the problem recently resolved in my previous tool post)
Essentially my two issues are: Not having the transformation jump back to the origin, and the rotation I cant seem to work it always just flips up onto its side.
My knowledge of vectors is pretty poor, so that very well might be the source of my issue.
Cheers,
Korbin~