Debian Codegraph @

texmf-dist/tex/latex/tkz-elements/tkz_elements_parallelogram.lua

raw
1 -- File: tkz_elements_parallelogram.lua
2 -- Copyright (c) 2026 Alain Matthes
3 -- SPDX-License-Identifier: LPPL-1.3c
4 -- Maintainer: Alain Matthes
5 ---------------------------------------------------------------------------
6 -- Parallelogram
7 ---------------------------------------------------------------------------
8
9 parallelogram = {}
10 parallelogram.__index = parallelogram
11 function parallelogram:new(pa, pb, pc, pd)
12 local d
13 local zi = midpoint_(pa, pc)
14 local zj = midpoint_(pb, pd)
15 if point.abs(zj - zi) < tkz.epsilon then
16 else
17 tex.error("it's not a parallelogram")
18 end
19 local type = "parallelogram"
20 local center = zi
21 local ab = line:new(pa, pb)
22 local bc = line:new(pb, pc)
23 local cd = line:new(pc, pd)
24 local da = line:new(pd, pa)
25 local ac = line:new(pa, pc)
26 local bd = line:new(pb, pd)
27 local o = {
28 pa = pa,
29 pb = pb,
30 pc = pc,
31 pd = pd,
32 ab = ab,
33 ac = ac,
34 bc = bc,
35 da = da,
36 cd = cd,
37 bd = bd,
38 center = center,
39 type = type,
40 }
41 setmetatable(o, self)
42 return o
43 end
44
45 setmetatable(parallelogram, {
46 __call = function(cls, ...)
47 return cls:new(...)
48 end,
49 })
50
51 function parallelogram:get()
52 return self.pa, self.pb, self.pc, self.pd
53 end
54
55 return parallelogram