| 1 |
-- File: tkz_elements_functions_square.lua |
| 2 |
-- Copyright (c) 2026 Alain Matthes |
| 3 |
-- SPDX-License-Identifier: LPPL-1.3c |
| 4 |
-- Maintainer: Alain Matthes |
| 5 |
|
| 6 |
function square_by_rotation_(zi, za) |
| 7 |
local zb = rotation_(zi, math.pi / 2, za) |
| 8 |
local zc = rotation_(zi, math.pi / 2, zb) |
| 9 |
local zd = rotation_(zi, math.pi / 2, zc) |
| 10 |
return square:new(za, zb, zc, zd) |
| 11 |
end |
| 12 |
|
| 13 |
function square_from_side_(pa, pb, swap) |
| 14 |
swap = (swap == "swap") or (swap == true) |
| 15 |
local pc, pd |
| 16 |
if swap then |
| 17 |
pc = rotation_(pb, math.pi/2, pa) |
| 18 |
pd = rotation_(pa, -math.pi/2, pb) |
| 19 |
else |
| 20 |
pc = rotation_(pb, -math.pi/2, pa) |
| 21 |
pd = rotation_(pa, math.pi/2, pb) |
| 22 |
end |
| 23 |
return square:new(pa, pb, pc, pd) |
| 24 |
end |
| 25 |
|
| 26 |
square.by_rotation = square_by_rotation_ |
| 27 |
square.from_side = square_from_side_ |