Pickray
-
Hello to all,
There's something I don't understand (no, many things) and that's about pickray.
Suppose I have a model existing of a single edge. Then I create a ray from the eye through one of the two endpoints of the on screen projection and try to find the intersection of that ray with the edge. Why is the ray (a line) missing the edge? I'm totally confused because I presumed that the result had to be the startposition (or endposition, depending of the screencoordinates) of the edge.An example
def exp_a mod = Sketchup.active_model view = mod.active_view ents = mod.entities ents.clear! edges = ents.add_edges([0, 0, 0] , [100, 100, 100]) edge = edges[0] pt = view.screen_coords(edge.start.position) ray = view.pickray(pt.x, pt.y) Geom.intersect_line_line(edge.line, ray) end
The result is nil.
Can anybody tell me what is wrong with my assumption that in this case the result should be [0, 0, 0]? What is wrong with my understanding of pickray?
-
Maybe due to precision issue?
Not sure, but you don't have to convert between screenpoints like that:mod = Sketchup.active_model view = mod.active_view ents = mod.entities ents.clear! edges = ents.add_edges([0, 0, 0] , [100, 100, 100]) edge = edges[0] pt1 = edge.start.position pt2 = view.camera.eye Geom.intersect_line_line(edge.line, [pt1, pt2])
Advertisement