File: test_arclength.py

package info (click to toggle)
python-beziers 0.6.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 672 kB
  • sloc: python: 3,160; makefile: 20
file content (29 lines) | stat: -rw-r--r-- 741 bytes parent folder | download | duplicates (2)
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
import unittest
from beziers.quadraticbezier import QuadraticBezier
from beziers.cubicbezier import CubicBezier
from beziers.point import Point

class ArcLengthMethods(unittest.TestCase):
  def test_quadraticLength(self):
    b1 = QuadraticBezier(
      Point(150,40),
      Point(80,30),
      Point(105,150)
    )
    self.assertAlmostEqual(b1.length, 144.79561403359523)

    b2 = QuadraticBezier(
      Point(707,596),
      Point(645,596),
      Point(592,623)
    )
    self.assertAlmostEqual(b2.length, 119.25113694489232)

  def test_cubicLength(self):
    b1 = CubicBezier(
        Point(100,25),
        Point(10,90),
        Point(110,100),
        Point(132,192)
      )
    self.assertAlmostEqual(b1.length, 202.20118972656385)