diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-05-02 17:59:13 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-02 17:59:13 +0000 |
commit | f4cdc443fb86f715ab93f3528aff23452a5bb3a3 (patch) | |
tree | ffab5077611d32a8b95c9d9b4f96b47703190e82 /utils/hacks/TreeGraphs/Graphics/Geometry/Intersect2D.py | |
parent | bae2fa50234b0a575a18a119019e5d96f7ff7ecf (diff) | |
download | klee-f4cdc443fb86f715ab93f3528aff23452a5bb3a3.tar.gz |
Add a little hack for visualizing KLEE branching.
- This consumes the treestream files produced with --write-paths or --write-sym-paths, and renders out the tree in a very ad-hoc funky way. Your mileage may vary! :) Example image: http://klee.llvm.org/data/treegraph_example.jpg Example movie: http://klee.llvm.org/data/treegraph_example.avi git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@102869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/hacks/TreeGraphs/Graphics/Geometry/Intersect2D.py')
-rw-r--r-- | utils/hacks/TreeGraphs/Graphics/Geometry/Intersect2D.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/utils/hacks/TreeGraphs/Graphics/Geometry/Intersect2D.py b/utils/hacks/TreeGraphs/Graphics/Geometry/Intersect2D.py new file mode 100644 index 00000000..a600a64f --- /dev/null +++ b/utils/hacks/TreeGraphs/Graphics/Geometry/Intersect2D.py @@ -0,0 +1,59 @@ +import vec2, math + +def intersectLineCircle((p, no), (C, r)): + x = vec2.sub(p,C) + b = 2.*vec2.dot(no, x) + c = vec2.sqr(x) - r*r + dist = b*b - 4*c + + if dist<0: + return None + else: + d = math.sqrt(dist) + t0 = (-b - d)*.5 + t1 = (-b + d)*.5 + return (t0,t1) + +#def intersectLineCircle((lineP,lineN),(circleP,circleR)): +# dx,dy = vec2.sub(lineP,circleP) +# nx,ny = lineN +# +# a = (nx*nx + ny*ny) +# b = 2*(dx*nx + dy*ny) +# c = (dx*dx + dy*dy) - circleR*circleR +# +# k = b*b - 4*a*c +# if k<0: +# return None +# else: +# d = math.sqrt(k) +# t1 = (-b - d)/2*a +# t0 = (-b + d)/2*a +# return t0,t1 + +def intersectCircleCircle(c0P, c0R, c1P, c1R): + v = vec2.sub(c1P, c0P) + d = vec2.length(v) + + R = c0R + r = c1R + + try: + x = (d*d - r*r + R*R)/(2*d) + except ZeroDivisionError: + if R<r: + return 'inside',() + elif r>R: + return 'outside',() + else: + return 'coincident',() + + k = R*R - x*x + if k<0: + if x<0: + return 'inside',() + else: + return 'outside',() + else: + y = math.sqrt(k) + return 'intersect',(vec2.toangle(v),vec2.toangle((x,y))) |