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) endThe 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])
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement