Skip to content

Commit d5e56c5

Browse files
author
Judd
committed
add copyright notes
1 parent 06b3e93 commit d5e56c5

File tree

5 files changed

+86
-11
lines changed

5 files changed

+86
-11
lines changed

new/geometry.nim

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2025 github/foldl
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
116
import std/tables
217
from std/sequtils import zip
318
import sets
@@ -18,6 +33,8 @@ type
1833
num*: RootRef
1934
change: HashSet[Node[DepsT]]
2035

36+
new_name: string = ""
37+
2138
Point*[DepsT] = ref object of Node[DepsT]
2239

2340
Line*[DepsT] = ref object of Node[DepsT]
@@ -29,14 +46,15 @@ type
2946
Direction*[DepsT] = ref object of Node[DepsT]
3047

3148
Angle*[DepsT] = ref object of Node[DepsT]
32-
d: tuple[n1: Node[DepsT], n2: Node[DepsT]]
49+
d: tuple[n1: Direction[DepsT], n2: Direction[DepsT]]
3350

3451
Measure*[DepsT] = ref object of Node[DepsT]
3552

3653
Length*[DepsT] = ref object of Node[DepsT]
3754
d: tuple[n1: Node[DepsT], n2: Node[DepsT]]
3855

3956
Ratio*[DepsT] = ref object of Node[DepsT]
57+
l: (Length[DepsT], Length[DepsT])
4058

4159
Value*[DepsT] = ref object of Node[DepsT]
4260

new/graph_utils.nim

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# Copyright 2025 github/foldl
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
116
# Utilizations for graph representation.
217
# Mainly for listing combinations and permutations of elements.
318

new/n_utils.nim

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2025 github/foldl
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
16+
func seq2tuple2*[T](args: openArray[T]): (T, T) = (args[0], args[1])
17+
func seq2tuple3*[T](args: openArray[T]): (T, T, T) = (args[0], args[1], args[2])
18+
func seq2tuple4*[T](args: openArray[T]): (T, T, T, T) = (args[0], args[1], args[2], args[3])
19+
func seq2tuple5*[T](args: openArray[T]): (T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4])
20+
func seq2tuple6*[T](args: openArray[T]): (T, T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4], args[5])
21+
func seq2tuple7*[T](args: openArray[T]): (T, T, T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4], args[5], args[6])
22+
func seq2tuple8*[T](args: openArray[T]): (T, T, T, T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7])
23+
24+
func seq2tuple*[T](args: openArray[T]): tuple =
25+
case len(args)
26+
of 2: result = seq2tuple2(args)
27+
of 3: result = seq2tuple3(args)
28+
of 4: result = seq2tuple4(args)
29+
of 5: result = seq2tuple5(args)
30+
of 6: result = seq2tuple6(args)
31+
of 7: result = seq2tuple7(args)
32+
of 8: result = seq2tuple8(args)
33+
else: raise newException(ValueError, "")

new/numericals.nim

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
1+
# Copyright 2025 github/foldl
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
116
import std/math
2-
from std/fenv import epsilon
317
from std/random import rand
418
import std/[strformat, options, random, sequtils, sugar]
519

6-
import geometry as gm
20+
import geometry as gm
21+
import n_utils
722

823
const ATOM = 1e-12
924

@@ -486,13 +501,6 @@ proc check_too_far*(newpoints, points: openArray[Point]; tol: float = 4): bool =
486501
return true
487502
return false
488503

489-
func seq2tuple2*[T](args: openArray[T]): (T, T) = (args[0], args[1])
490-
func seq2tuple3*[T](args: openArray[T]): (T, T, T) = (args[0], args[1], args[2])
491-
func seq2tuple4*[T](args: openArray[T]): (T, T, T, T) = (args[0], args[1], args[2], args[3])
492-
func seq2tuple5*[T](args: openArray[T]): (T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4])
493-
func seq2tuple6*[T](args: openArray[T]): (T, T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4], args[5])
494-
func seq2tuple8*[T](args: openArray[T]): (T, T, T, T, T, T, T, T) = (args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7])
495-
496504
proc check_aconst*(args: seq[RootRef]): bool =
497505
var (ra, rb, rc, rd, rnum, rden) = seq2tuple6(args)
498506
var (a, b, c, d) = (Point(ra), Point(rb), Point(rc), Point(rd))

new/tests/test_numericals.nim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import sets
55
import std/[algorithm, strformat, math, random, options]
66

77
import ../numericals as nm
8+
import ../n_utils
89

910
proc assertEqual[A, B](a: A; b: B) =
1011
assert a == b, fmt"{a} != {b}"
@@ -51,7 +52,7 @@ proc test_sketch_2l1c() =
5152
assertAlmostEqual(i.distance(x), i.distance(z))
5253
5354
proc test_sketch_3peq() =
54-
let (a, b, c) = seq2tuple3(random_points(3))
55+
let (a, b, c) = seq2tuple3 random_points(3)
5556
let (x, y, z) = nm.sketch_3peq([a, b, c])
5657
5758
assert(check_coll([a, b, x]))

0 commit comments

Comments
 (0)