-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdimensions
57 lines (42 loc) · 1.05 KB
/
dimensions
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
48
49
50
51
52
53
54
55
56
57
import geometry2d
def dim(vec1 as Vector vec2 as Vector textSize as Number) = {
#ref line
#line(vec1.x vec1.y vec2.x vec2.y)
def a = vec1.x
def b = vec1.y
def c = vec2.x
def d = vec2.y
def movedVx2 = c - a + 30
def movedVy2 = d - b + 20
def rX = (movedVy2) / textSize
def rY = (movedVx2) / textSize * 2
#DIMENSION LINE
def e1x = a + rX
def e1y = b + rY
def e2x = c + rX
def e2y = d + rY
line(e1x e1y e2x e2y)
#END TICKS
def tick1x = Rx / -6
def tick1y = Ry / -6
def tick2x = Rx / 14
def tick2y = Ry / 14
line(tick1x + e1x tick1y + e1y tick2x + e1x tick2y + e1y)
line(tick1x + e2x tick1y + e2y tick2x + e2x tick2y + e2y)
#text
def middlex = if(a < 0 ) {(a - (a - c) / 2)} else {(c - (c - a) / 2)}
def middley = if(b > 0 ) {(b - (b - d) / 2)} else {(d - (d - b) / 2)}
def textX = middlex + ( rX * (textSize / 3))
def textY = middley + ( rY * (textSize / 3.2))
def t = length(vec1 vec2)
text(textX textY textSize round(t))
}
#TEST
def i = Vector(0 0)
def n = Vector(120 0)
def o = Vector(120 0)
def p = Vector(120 -50)
dim(i n 6)
dim(n i 6)
dim(p o 6)
dim(o p 6)