problem with computing plan intersection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

problem with computing plan intersection

khenyh
Hi,

I need to compute the point of intersection between a plan and a line.

I use the "intersectingPointWithLine: aLine" method of  JunPlane class.

I noticed a difference with the same but oldest method (Jun 004) (this oldest version is used in a program) and the results are different for a given plan and line ! (no difference with the exemples given).

And I can't find which method is correct.


I have bolded and underlined the differences.




Here is the oldest version :

intersectingPointWithLine: aLine

    "(Jun3dPlane

    on: (Jun3dPoint fromArray: #(-2 -2 0))

    on: (Jun3dPoint fromArray: #(0 2 0))

    on: (Jun3dPoint fromArray: #(2 0 0)))

    intersectingPointWithLine:

    (Jun3dLine

    from: (Jun3dPoint fromArray: #(0 0 1))

    to: (Jun3dPoint fromArray: #(0 0 2)))."



    | theLine denominator t |

    (aLine isKindOf: self class)

        ifTrue: [theLine := aLine]

        ifFalse: [theLine := Jun3dLine from: aLine first to: aLine last].

    denominator := self a * theLine f + (self b * theLine g) + (self c * theLine h).

    denominator abs < self class accy ifTrue: ["parallel"

        ^nil].

    t := (self a * theLine x0 + (self b * theLine y0) + (self c * theLine z0) + self d / denominator) negated.

    ^Jun3dPoint

        x: theLine x0 + (theLine f * t)

        y: theLine y0 + (theLine g * t)

        z: theLine z0 + (theLine h * t)






And now the new version :

intersectingPointWithLine: aLine
    "(-2 , -2 , 0 plane: 0 , 2 , 0 and: 2 , 0 , 0)
        intersectingPointWithLine: (0 , 0 , -2 to: 0 , 0 , 2)."

    "(0 , 0 , 0 plane: 1 , 0 , 0 and: 0 , 1 , 0)
        intersectingPointWithLine: (0 , 0 , -2 to: 0 , 0 , -1)."

    | theLine denominator thePoint numerator |
self halt.
    (aLine isKindOf: Jun3dLine)
        ifTrue: [theLine := aLine]
        ifFalse: [theLine := Jun3dLine from: aLine first to: aLine last].
    denominator := a * theLine f + (b * theLine g) + (c * theLine h).
    denominator abs < aLine class accuracy
        ifTrue:
            ["parallel"

            ^nil].
    numerator := (a * theLine x0 + (b * theLine y0) + (c * theLine z0) + d)
                negated.
    thePoint := Jun3dPoint
                x: theLine x0 + (theLine f * numerator / denominator)
                y: theLine y0 + (theLine g * numerator / denominator)
                z: theLine z0 + (theLine h * numerator / denominator).
    ^thePoint




There must be an error in one or the other version, but which is correct ?

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc