-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPointCutter.inc
47 lines (36 loc) · 1.13 KB
/
PointCutter.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "math.inc"
#include "RotMatFromVectorAndAngle.inc"
/*
Returns a halfspace that contains `PointT` on its surface
and is perpendicular to the line through the origin and `PointT`.
The volume of the halfspace is outside, i.e. the origin is not in it.
`Offset` will move the box towards the origin.
*/
#macro PointCutter(PointT, Offset)
// The volume of this halfspace is all points with positive x.
#local Halfspace = plane{ -x, 1 translate x }
#if (PointT.y=0 & PointT.z=0)
#if (PointT.x>0)
object{
Halfspace
translate ( PointT.x - Offset ) * x
}
#else
object{
Halfspace
scale -x
translate ( PointT.x + Offset ) * x
}
#end
#else
#local Dist = VDist(<0, 0, 0>, PointT);
#local Point0 = <Dist, 0, 0>;
#local Angle = VAngle(PointT, Point0);
#local Perp = VPerp_To_Plane(PointT, Point0);
object{
Halfspace
translate (Dist-Offset)*x
RotMatFromVectorAndAngle(Perp, Angle)
}
#end
#end