5 Geometry
(require sfont/geometry) | package: sfont |
This is the module for vector operations, transformations and bezier paths.
value
procedure
(geometric? o) → boolean?
o : any/c
procedure
(transform o m) → geometric?
o : geometric? m : trans-mat?
procedure
(translate o x y) → geometric?
o : geometric? x : real? y : real?
procedure
(rotate o angle) → geometric?
o : geometric? angle : real?
procedure
(scale o fx [fy]) → geometric?
o : geometric? fx : real? fy : real? = fx
procedure
(skew-x o angle) → geometric?
o : geometric? angle : real?
procedure
(skew-y o angle) → geometric?
o : geometric? angle : real?
procedure
(reflect-x o) → geometric?
o : geometric?
procedure
(reflect-y o) → geometric?
o : geometric?
procedure
(vec-approx= v1 v2) → boolean?
v1 : vec? v2 : vec?
procedure
(translation-matrix x y) → trans-mat?
x : real? y : real?
procedure
(rotation-matrix angle) → trans-mat?
angle : real?
procedure
(scale-matrix fx [fy]) → trans-mat?
fx : real? fy : real? = fx
procedure
(shear-matrix x y) → trans-mat?
x : real? y : real?
procedure
(trans-mat* m1 m2) → trans-mat?
m1 : trans-mat? m2 : trans-mat?
procedure
(trans-mat-vec* m v) → vec3?
m : trans-mat? v : vec3?
procedure
(dot-prod-3 v1 v2) → real?
v1 : vec3? v2 : vec3?
procedure
(cross-prod-2d v1 v2) → real?
v1 : vec? v2 : vec?
procedure
(segment-intersection v1 v2 v3 v4) → (or/c vec? #f)
v1 : vec? v2 : vec? v3 : vec? v4 : vec?
procedure
(signed-area v1 v2) → real?
v1 : vec? v2 : vec?
procedure
(signed-polygonal-area lov) → real?
lov : (listof vec?)
procedure
(pass-through-hor? h v1 v2) → boolean?
h : real? v1 : vec? v2 : vec?
procedure
(pass-through-vert? v v1 v2) → boolean?
v : real? v1 : vec? v2 : vec?
5.1 Bezier Curves
In Sfont a ’bezier path’ is a list of vec, a segment is a bezier path with only two ’on-curve’ points.
value
value
value
value
value
procedure
b : bezier/c o : natural-number/c = 3
procedure
(on-curve-points b [o]) → (listof vec?)
b : bezier/c o : natural-number/c = 3
procedure
(off-curve-points b [o]) → (listof vec?)
b : bezier/c o : natural-number/c = 3
procedure
(end-points b) → (cons/c vec? vec?)
b : bezier/c
procedure
(line-segment? s) → boolean?
s : segment/c
procedure
s : cubic-segment/c
procedure
(split-at-point s v) →
segment/c segment/c s : segment/c v : vec?
procedure
(join-beziers b1 b ...) → bezier/c
b1 : bezier/c b : bezier/c
procedure
(polygonize-segment s n) → (listof vec?)
s : segment/c n : natural-number/c
procedure
s : segment/c
procedure
s : segment/c
procedure
s : segment/c
procedure
(bezier-bounding-box b [o]) → bounding-box/c
b : bezier/c o : natural-number/c = 3
procedure
(bezier-signed-area b [o s]) → real?
b : bezier/c o : natural-number/c = 3 s : natural-number/c = 200
procedure
(bezier-area b [o s]) → (and/c real? positive?)
b : bezier/c o : natural-number/c = 3 s : natural-number/c = 200
procedure
(clockwise? b) → boolean?
b : bezier/c
procedure
(cubic-bezier-intersections b1 b2) → (listof vec?)
b1 : cubic-bezier/c b2 : cubic-bezier/c
procedure
s1 : cubic-segment/c s2 : cubic-segment/c
procedure
(line-segment-intersections l s) → (listof vec?)
l : segment/c s : segment/c
procedure
(segment-intersect-hor h s) → (listof vec?)
h : real? s : segment/c
procedure
(segment-intersect-vert v s) → (listof vec?)
v : real? s : segment/c
procedure
(bezier-intersect-hor h s) → (listof vec?)
h : real? s : segment/c
procedure
(bezier-intersect-vert v s) → (listof vec?)
v : real? s : segment/c
procedure
(bezier-boundaries-hor h s) → bounding-box/c
h : real? s : segment/c
procedure
(point-inside-bezier? v b) → boolean?
v : vec? b : closed-bezier/c
procedure
(bezier->path b path) → (is-a?/c dc-path%)
b : cubic-bezier/c path : (is-a?/c dc-path%)
procedure
(print-beziers b ...) → pict?
b : cubic-bezier/c
5.1.1 Boolean operations
procedure
(bezier-subtract b1 b2) → (listof closed-bezier/c)
b1 : closed-bezier/c b2 : closed-bezier/c
procedure
(bezier-union b1 b2) → (listof closed-bezier/c)
b1 : closed-bezier/c b2 : closed-bezier/c
procedure
(bezier-intersection b1 b2) → (listof closed-bezier/c)
b1 : closed-bezier/c b2 : closed-bezier/c
5.2 Bounding Boxes
value
procedure
(combine-bounding-boxes bb b ...) → bounding-box/c
bb : bounding-box/c b : bounding-box/c
procedure
(inside-bounding-box? v bb) → boolean?
v : vec? bb : bounding-box/c
procedure
(overlap-bounding-boxes? bb1 bb2) → boolean?
bb1 : bounding-box/c bb2 : bounding-box/c
procedure
(include-bounding-box? bb1 bb2) → boolean?
bb1 : bounding-box/c bb2 : bounding-box/c