8000 GitHub - wbabic/complex: a clojure/clojurescript implementation of extended complex numbers
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ complex Public

a clojure/clojurescript implementation of extended complex numbers

License

Notifications You must be signed in to change notification settings

wbabic/complex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Complex Library

A cross platform library for exact extended complex numbers, geometry and transform.

Usage

clojure repl

lein repl

using a test runner in test/complex/test-runner.cljc which can work from either clojure or clojurescript

(require 'complex.test-runner)
(complex.test-runner/runner)

or

lein test

nodejs repl

  • see dev/node-repl.clj to start a node repl from a clojure repl

run cljs test using nodejs

lein nodetest

an alias, which does a build:

lein cljsbuild once node-dev

and runs the built target from nodejs:

node resources/run.js

which calls the -main function in test/complex/node_test_runner.cljs

to install locally

git clone git@github.com:wbabic/complex.git
cd complex
lein install

Implementation

Terms

complex number addition, multiplication, one, zero, infinity subtraction, multiplication identity and inverse length angle conjugate point line triangle circle geometric transformations translation, dilation reflection - in a line or a circle reciprocation

transforms using + - * / bar circle preserving transformations orientation preserving and reversing

transformable - able to be transformed renderable - able to be rendered

protocols Complex Transform Transformable Renderable

Data

geometric types: point line circle triangle style combined in a sequence, rendered to the canvas or, eventually, to svg and webgl

  • Number types Complex number with algebraic operations of addition and multiplication
  • Transform types Mobius transformations that can be composed and conjugated and have inverses preserving generalized circles
  • Pencils of circles and their orthogonal compliments and their images illustrating a particular transform, associated with that transfrom

able to be generated and validated passed over the wire, using transit saved in a database or a file as edn

Transformation properties

entries a b c d determinant trace inverse fixed points

Conjugation

of a mobius transformation with translation, rotation, scaling

Vector

in vector.cljc algebraic operations for vectors and matrices

sum product scal-mul dot len len-sq angle midpoint mvmult mmmult mat-inverse

Number

in number.cljc

represented as a vector of two rational numbers [x y] or [r a] with the possibility of being infinity where 1/zero = infinity and 1/infinity = zero and zero/zero = infinity/infinity = undefined

complex numbers can be added, multiplied and conjugated they have a length and an angle

Transform

linear fractional transformation in trasnform.cljc

represented as a vector of four complex numbers [a b c d] that can be normalized so that ad - bc = 1 has a determinant, trace, inverse can be composed and conjugated

translation rotation scaling inversion all represented as 4-vectors of complex number

composition of transformation implemented as matrix multipliation of 2x2 complex matrices

inverse of a transformation as inverse of a 2x2 matrix conjugation by a conjugataing map as composition of three matrices

Geometry

image of a generalized circle in geometry.cljc

Grandma’s recipe and project 3.7 in Indra’s Pearls

my idea: image of a line line represented by two points look at image of the two points and of their midpoint they are either collieanr, in which case the image of the line is a line or they form a triangle, in which case the image of the line is a circle, the circumcircle of the triangle

so what is the circumcircle of a triangle? the circumcenter is the intesection of the perpendicualr bisectors the radius is the distance from the circumcenter to one of the vertices of the triangle see illuminated triangle

todo: look at method from geometry of complex numbers where a generalized circle is repsesented as a Hermitian matrix

Extended line segment

extend a line segment between two points to a whole line

given two points, p1 p2, there are three parts: the finite segment p1 to p2 the infinite segments from infinity to p1 and from p2 to infinity

the image of the three parts can also be distinguished

Generalized circle

given three points the circumcircle of a triangle, if not collinear or a line, a circle passing through infinity, if collinear

Parameterized circle

z = (at + b)/(ct + d) generalized equation z*zbar + a*z + abar*zbar + b = 0 center = -abar radius = a*abar - b

example: z = (1 + it)/(1 - it) z1 z0 z_infinity

constructed and calibrated

passing through three given points, p q and r at t = 0, 1 and infinity, respectively see Deaux

Math references

Introduction to Geometry Coxeter

Indra’s Pearls The vision of Felix Klein Mumford, Series, Wright

Visual Complex Analysis Tristan Needham

Geometry of Complex Numbers Hans Schwerdttfeger

Introduction to the Geometry of Complex Numbers Roland Deaux

Technologies

Reader Conditionals

Unit test in Clojure and ClojureScript

clojurescript testing https://github.com/clojure/clojurescript/wiki/Testing

Test.check

generative tests https://github.com/clojure/test.check

Prismatic Schema

for documentation and testing

references

blog: http://blog.getprismatic.com/schema-for-clojurescript-data-shape-declaration-and-validation/ docs: http://prismatic.github.io/schema/

github: https://github.com/Prismatic/schema

contracts as types

https://github.com/jessitron/contracts-as-types-examples/blob/master/test/contractypes/report_example_test.clj https://github.com/jessitron/contracts-as-types-examples https://github.com/jessitron/schematron

Philly ETE 2015 #4 Contracts & Clojure: The Best-Yet Compromise of Types and Tests Jessica Kerr https://www.youtube.com/watch?v=GFQqyXoL0YQ http://www.slideshare.net/jessitron/contracts-inclojurepete

david mcneil extending prismatic schema to higher order http://david-mcneil.com/post/114783282473/extending-prismatic-schema-to-higher-order https://gist.github.com/david-mcneil/a46b091c05a91adb8336

code

(def Point [s/Num])
(def Circle "a schema for circles" {:center Point :radius s/Num})

(s/check Circle {:center [0 0] :radius 1})
(s/validate Circle {:center [0 0] :radius 1})

(def circle [(s/one s/Keyword "tag") (s/one Circle "data")])
(s/check circle [:circle {:center [0 0] :radius 1}])

how to describe [:triangle p1 p2 p3]

for instance a point is a single complex number a line, two complex numbers a triangle made up of three complex numbers, if not collinear, has a circumcircle - a circumcenter and a radius a transform can be applied to a point a line or a triangle and consists of complex addition and multiplication along with subtraction and division with refelction and inversion using the complex conjugate

Core.match

About

a clojure/clojurescript implementation of extended complex numbers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0