Giter VIP home page Giter VIP logo

geometer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

geometer's Issues

Point to Line distance error

I'm using Python 3.8.10 with geometer 0.2.3. This code snippet:

p0 = Point(1, 2, 0)
l0 = Line(Point(0, 0, 0), Point(3, 0, 0))
print(dist(p0, l0))

produces this exception:

Traceback (most recent call last):
  File "/home/paul/upwork/pick/code/test-geometer.py", line 14, in <module>
    print(dist(p0, l0))
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/operators.py", line 243, in dist
    return dist(q.project(p), p)
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/point.py", line 511, in project
    l = self.perpendicular(pt)
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/point.py", line 495, in perpendicular
    return self.mirror(through).join(through)
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/point.py", line 596, in mirror
    result = m1.meet(m2)
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/point.py", line 339, in meet
    return meet(self, *others)
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/point.py", line 113, in meet
    return _join_meet_duality(*args, intersect_lines=True)
  File "/home/paul/upwork/pick/code/.pick/lib/python3.8/site-packages/geometer/point.py", line 65, in _join_meet_duality
    raise LinearDependenceError("Arguments are not linearly independent.")
geometer.exceptions.LinearDependenceError: Arguments are not linearly independent.

Help using Circles intersection

Hello, trying to use your library for mechanical calculation but not being a mathematicians I don't understand how to use the result of intersection of circles.

C1 = Circle(Point(0,0),5)
C2 = Circle(Point(8,0),5)
l = Line(Point(4,0), Point(4,1))
A = C1.intersect(C2)
B = C1.intersect(l)
C = C2.intersect(l)

This is the result of circles intersection

A
[Point((5.014458341998072+0.010710064639031416j), (0.13325313668481312-0.40303121043641016j)),
 Point((19.770205823088897-0.16649271512070937j), (0.17208666613531612+19.12754381209912j)),
 Point((19.770205823088894-0.16649271512071231j), (-0.17208666613532006-19.12754381209912j)),
 Point((5.014458341998073+0.010710064639031925j), (-0.1332531366848131+0.4030312104364105j))]

The expected points are on both intersections of line with circles

Point(4.0,3.0) in B
True
Point(4.0,-3.0) in B
True
Point(4.0,3.0) in C
True
Point(4.0,-3.0) in C
True

But not on intersection of circles

Point(4.0,3.0) in A
False
Point(4.0,-3.0) in A
False

What am I missing ?
Thanks an best regards

Unable to install the package. SSL problem

Hello,

There is a problem with an SSL certificate of a site with the package:

Collecting geometer
WARNING: Certificate did not match expected hostname: files.pythonhosted.org. Certificate: {'subject': ((('commonName', 'm.sni-311-default.ssl.fastly.net'),),), 'issuer': ((('countryName', 'US'),), (('organiz
ationName', 'Certainly'),), (('commonName', 'Certainly Intermediate R1'),)), 'version': 3, 'serialNumber': '770C351AB42DB7F9AF0E2E9BDBA20001978A', 'notBefore': 'Jan 27 02:45:14 2024 GMT', 'notAfter': 'Feb 26 02
:45:13 2024 GMT', 'subjectAltName': (('DNS', 'm.sni-311-default.ssl.fastly.net'),), 'OCSP': ('http://ocsp.int-r1.certainly.com',), 'caIssuers': ('http://int-r1.certainly.com',)}
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(CertificateError("hostname 'files.pythonhosted.org' doesn't match 'm.sni-311-defaul
t.ssl.fastly.net'"))': /packages/07/72/ea96b9dba247498e063d353e1f2acd4ff8d90bef87935f1cdfeb04386849/geometer-0.3.5-py3-none-any.whl
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/07/72/ea96b9dba247498e063d353e1f2acd4ff8d90bef87935f1c
dfeb04386849/geometer-0.3.5-py3-none-any.whl (Caused by SSLError(CertificateError("hostname 'files.pythonhosted.org' doesn't match 'm.sni-311-default.ssl.fastly.net'")))

ValueError thrown during intersection between rectangle and segment

from geometer import *

foo = Rectangle(Point(148.06094049635456, 10.151151779987144, 60.522099063951394), Point(129.78569335065157, -42.129870038015355, 60.54878245579997), Point(85.91668756014471, -26.79517716452499, 60.41723371984577), Point(104.19193470584759, 25.485844653477507, 60.390550327997126))
bar = Segment(Point(-38.9592826559563, -6.703132040294841, 64.78693707404751), Point(133.01711836447913, -6.633886165038485, 54.310634812542006))

print(foo.intersect(bar))

Sorry about the ugly numbers with this one. This rectangle and segment shouldn't intersect, but when run it throws a ValueError.

Traceback (most recent call last):
...
ValueError: not enough values to unpack (expected 2, got 1)

Bug: Working with non-trivial numerical objects

I wanted to use a Fraction object like something present in the fractions module, but I cannot seem to build lines from points. Here is an example:

from fractions import Fraction
from geometer import Point, Line

p = Point(Fraction(1/3), Fraction(2/3))
q = Point(Fraction(1/2), Fraction(-1/9))

line = Line(p, q)

The last line fails with a numpy einsum issue because there is no "object_einsum" implemented. The traceback is:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-d1a83d5167a7> in <module>
----> 1 Line(p, q)

~/.local/share/virtualenvs/qgeo-Wd1mrhuZ/lib/python3.7/site-packages/geometer/point.py in __init__(self, *args)
    339         if len(args) == 2:
    340             pt1, pt2 = args
--> 341             super(Line, self).__init__(pt1.join(pt2))
    342         else:
    343             super(Line, self).__init__(*args)

~/.local/share/virtualenvs/qgeo-Wd1mrhuZ/lib/python3.7/site-packages/geometer/point.py in join(self, *others)
    179
    180         """
--> 181         return join(self, *others)
    182
    183

~/.local/share/virtualenvs/qgeo-Wd1mrhuZ/lib/python3.7/site-packages/geometer/point.py in join(*args)
     87
     88     """
---> 89     return _join_meet_duality(*args, intersect_lines=False)
     90
     91

~/.local/share/virtualenvs/qgeo-Wd1mrhuZ/lib/python3.7/site-packages/geometer/point.py in _join_meet_duality(intersect_lines, *args)
     19         e = LeviCivitaTensor(n, not covariant)
     20         diagram = TensorDiagram(*[(o, e) if covariant else (e, o) for o in args])
---> 21         result = diagram.calculate()
     22
     23     elif len(args) == 2:

~/.local/share/virtualenvs/qgeo-Wd1mrhuZ/lib/python3.7/site-packages/geometer/base.py in calculate(self)
    211         result_indices = result_indices[0] + result_indices[1]
    212
--> 213         x = np.einsum(*args, result_indices)
    214         return Tensor(x, covariant=range(cov_count))
    215

~/.local/share/virtualenvs/qgeo-Wd1mrhuZ/lib/python3.7/site-packages/numpy/core/einsumfunc.py in einsum(*operands, **kwargs)
   1344     # If no optimization, run pure einsum
   1345     if optimize_arg is False:
-> 1346         return c_einsum(*operands, **kwargs)
   1347
   1348     valid_einsum_kwargs = ['out', 'dtype', 'order', 'casting']

TypeError: invalid data type for einsum

Is there a way to fix this in geometer? Maybe use the more specific type of a tensor summation to perform the calculation you need here instead of the general einsum. It would be very nice to be able to use any numerical objects here.

Note: This also fails for sympy symbol objects.

Synergies

Dear Jan,

I didn't know how else to contact you. I just took some spare time to upload toy projects of mine and before uploading to pypy I found your geometer project. There's some overlap and potential for synergies in the code.

https://github.com/aaichert/ProjectiveGeometry23

If you're interested in merging the whole projection matrix / source detector geometry things into geometer, hit me up.

Best,

Andre

Issues with small angle calculations

Dear Sirs,
I have run into an issue when trying to calculate small angles using geometer. The geometry I am setting up is basically two intersecting lines, and the for loop is changing the geometry so the two lines are both rotating (as position in front of vehicle grows larger), and the angle between them is growing smaller.
At a certain point, the angle between the lines goes from a (small) positive value, to zero (around 16.6m in front of the vehicle). I think there may be precision lost in the array calculations done calculating the angle:

PS Z:\my_python\GeometerTest> c:\python37\python.exe .\GeometerTest.py
Point on road in front of vehicle 10.0 meters changes image angle by: 0.48873293 degtrees
Point on road in front of vehicle 10.1 meters changes image angle by: 0.47939775 degtrees
Point on road in front of vehicle 10.2 meters changes image angle by: 0.47032307 degtrees
Point on road in front of vehicle 10.3 meters changes image angle by: 0.46149947 degtrees
Point on road in front of vehicle 10.4 meters changes image angle by: 0.45291791 degtrees
Point on road in front of vehicle 10.5 meters changes image angle by: 0.44456978 degtrees
Point on road in front of vehicle 10.6 meters changes image angle by: 0.43644682 degtrees
Point on road in front of vehicle 10.7 meters changes image angle by: 0.42854112 degtrees
Point on road in front of vehicle 10.8 meters changes image angle by: 0.42084514 degtrees
Point on road in front of vehicle 10.9 meters changes image angle by: 0.41335162 degtrees
Point on road in front of vehicle 11.0 meters changes image angle by: 0.40605365 degtrees
Point on road in front of vehicle 11.1 meters changes image angle by: 0.39894456 degtrees
Point on road in front of vehicle 11.2 meters changes image angle by: 0.39201799 degtrees
Point on road in front of vehicle 11.3 meters changes image angle by: 0.38526784 degtrees
Point on road in front of vehicle 11.4 meters changes image angle by: 0.37868825 degtrees
Point on road in front of vehicle 11.5 meters changes image angle by: 0.37227359 degtrees
Point on road in front of vehicle 11.6 meters changes image angle by: 0.36601847 degtrees
Point on road in front of vehicle 11.7 meters changes image angle by: 0.35991771 degtrees
Point on road in front of vehicle 11.8 meters changes image angle by: 0.35396635 degtrees
Point on road in front of vehicle 11.9 meters changes image angle by: 0.34815960 degtrees
Point on road in front of vehicle 12.0 meters changes image angle by: 0.34249288 degtrees
Point on road in front of vehicle 12.1 meters changes image angle by: 0.33696177 degtrees
Point on road in front of vehicle 12.2 meters changes image angle by: 0.33156203 degtrees
Point on road in front of vehicle 12.3 meters changes image angle by: 0.32628959 degtrees
Point on road in front of vehicle 12.4 meters changes image angle by: 0.32114051 degtrees
Point on road in front of vehicle 12.5 meters changes image angle by: 0.31611103 degtrees
Point on road in front of vehicle 12.6 meters changes image angle by: 0.31119751 degtrees
Point on road in front of vehicle 12.7 meters changes image angle by: 0.30639645 degtrees
Point on road in front of vehicle 12.8 meters changes image angle by: 0.30170449 degtrees
Point on road in front of vehicle 12.9 meters changes image angle by: 0.29711837 degtrees
Point on road in front of vehicle 13.0 meters changes image angle by: 0.29263497 degtrees
Point on road in front of vehicle 13.1 meters changes image angle by: 0.28825128 degtrees
Point on road in front of vehicle 13.2 meters changes image angle by: 0.28396440 degtrees
Point on road in front of vehicle 13.3 meters changes image angle by: 0.27977151 degtrees
Point on road in front of vehicle 13.4 meters changes image angle by: 0.27566993 degtrees
Point on road in front of vehicle 13.5 meters changes image angle by: 0.27165704 degtrees
Point on road in front of vehicle 13.6 meters changes image angle by: 0.26773033 degtrees
Point on road in front of vehicle 13.7 meters changes image angle by: 0.26388737 degtrees
Point on road in front of vehicle 13.8 meters changes image angle by: 0.26012582 degtrees
Point on road in front of vehicle 13.9 meters changes image angle by: 0.25644342 degtrees
Point on road in front of vehicle 14.0 meters changes image angle by: 0.25283798 degtrees
Point on road in front of vehicle 14.1 meters changes image angle by: 0.24930740 degtrees
Point on road in front of vehicle 14.2 meters changes image angle by: 0.24584962 degtrees
Point on road in front of vehicle 14.3 meters changes image angle by: 0.24246269 degtrees
Point on road in front of vehicle 14.4 meters changes image angle by: 0.23914469 degtrees
Point on road in front of vehicle 14.5 meters changes image angle by: 0.23589378 degtrees
Point on road in front of vehicle 14.6 meters changes image angle by: 0.23270818 degtrees
Point on road in front of vehicle 14.7 meters changes image angle by: 0.22958617 degtrees
Point on road in front of vehicle 14.8 meters changes image angle by: 0.22652608 degtrees
Point on road in front of vehicle 14.9 meters changes image angle by: 0.22352630 degtrees
Point on road in front of vehicle 15.0 meters changes image angle by: 0.22058526 degtrees
Point on road in front of vehicle 15.1 meters changes image angle by: 0.21770145 degtrees
Point on road in front of vehicle 15.2 meters changes image angle by: 0.21487340 degtrees
Point on road in front of vehicle 15.3 meters changes image angle by: 0.21209971 degtrees
Point on road in front of vehicle 15.4 meters changes image angle by: 0.20937899 degtrees
Point on road in front of vehicle 15.5 meters changes image angle by: 0.20670992 degtrees
Point on road in front of vehicle 15.6 meters changes image angle by: 0.20409120 degtrees
Point on road in front of vehicle 15.7 meters changes image angle by: 0.20152159 degtrees
Point on road in front of vehicle 15.8 meters changes image angle by: 0.19899987 degtrees
Point on road in front of vehicle 15.9 meters changes image angle by: 0.19652487 degtrees
Point on road in front of vehicle 16.0 meters changes image angle by: 0.19409545 degtrees
Point on road in front of vehicle 16.1 meters changes image angle by: 0.19171051 degtrees
Point on road in front of vehicle 16.2 meters changes image angle by: 0.18936897 degtrees
Point on road in front of vehicle 16.3 meters changes image angle by: 0.18706979 degtrees
Point on road in front of vehicle 16.4 meters changes image angle by: 0.18481197 degtrees
Point on road in front of vehicle 16.5 meters changes image angle by: 0.18259452 degtrees
Point on road in front of vehicle 16.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 16.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 16.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 16.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 17.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 18.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 19.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 20.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 21.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 22.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 23.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 24.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 25.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 26.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 27.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 28.9 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.0 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.1 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.2 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.3 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.4 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.5 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.6 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.7 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.8 meters changes image angle by: 0.00000000 degtrees
Point on road in front of vehicle 29.9 meters changes image angle by: 0.00000000 degtrees
PS Z:\my_python\GeometerTest>

Code to generate this output is below:

import geometer
import numpy as np

IlluminatorHeight = 1.41732
IlluminatorLocation = geometer.Point(0, 0, IlluminatorHeight) # All unit measurements converted to SI and stripped before use in geometry module
LaneMarkingSpacing = 3.5052

Now introduce motion of vehicle

VehicleSpeed = 26.8224
WP_BP_FrameRate = 70
RoadMotionDistance = VehicleSpeed / WP_BP_FrameRate
StartLanePoint = 10
for StartLanePoint in np.arange(10, 30, .1):
StartLanePointLocation = geometer.Point(geometer.Point(LaneMarkingSpacing/2, StartLanePoint, 0))
StartLanePointRay = geometer.Line(IlluminatorLocation, StartLanePointLocation)
EndLanePoint = StartLanePoint - RoadMotionDistance # Road point gets closer to car
EndLanePointLocation = geometer.Point(geometer.Point(LaneMarkingSpacing/2, EndLanePoint, 0))
EndLanePointRay = geometer.Line(IlluminatorLocation, EndLanePointLocation)
print("Point on road in front of vehicle {0:1.1f} meters changes image angle by: {1:1.8f} degtrees".format(StartLanePoint, np.rad2deg(np.real(geometer.angle(StartLanePointRay, EndLanePointRay)))))

Sincerely,
Duane

Implement operations in 3D

  • Meet line-plane
  • Meet plane-plane
  • Join line-point
  • Join point-point
  • Meet line-line
  • plane contains line
  • points coplanar
  • points collinear
  • parallel plane
  • orthogonal plane

Segment x Line intersection

left_edge = geometer.Point(-1, 0.1)
right_edge = geometer.Point(1, 0.1)
line = geometer.Line(right_edge, left_edge)
segment = geometer.Segment(right_edge, left_edge)
circle = geometer.Conic(np.diag([1, 1, -0.01]))
point = geometer.Point(0, 0.9)

polar_line = circle.polar(point)
polar_points = circle.intersect(polar_line)

ray = geometer.Line(polar_points[0], point)
x_1 = ray.meet(line)
x_2 = ray.meet(segment)

I would expect the intersection between line and ray to be the same as segment and ray as the ray intersects the segment.

What am I doing wrong?

Fixes for operations in higher dimensions

Some things don't work in four or higher dimensions. This includes the following operations:

  • basis_matrix for lines
  • mirror points at lines
  • intersect lines
  • mirror point at hyperplanes

Cannot run example in Readme: 'PointCollection' is not defined

When I run the example in the README I get NameError: name 'PointCollection' is not defined.

Installed with pip (version 0.2.3). Python version 3.8.

pip install geometer

Point is defined.

import geometer
help(geometer)

Help on package geometer:

NAME
    geometer

PACKAGE CONTENTS
    __version__
    base
    base2
    curve
    exceptions
    operators
    point
    shapes
    transformation
    utils (package)

DATA
    I = Point((-0-1j), (1+0j)) at Infinity
    J = Point(1j, (1+0j)) at Infinity
    infty = Line([0, 0, 1])
    infty_plane = Plane(0,0,0,1)

VERSION
    0.2.3

FILE
    /home/nrw/v3/lib/python3.8/site-packages/geometer/__init__.py

Similarly I can run such stuff as

>>> import geometer
>>> geometer.PointCollection()
AttributeError: module 'geometer' has no attribute 'PointCollection'

Failure to determine intersections after rotation

from geometer import *

foo = Cuboid(Point(0,0,-10), Point(1,0,-10), Point(0,1,-10), Point(0,0,10))
bar = Cuboid(Point(-10,-10,0), Point(10,-10,0), Point(-10,10,0), Point(-10,-10,1))

transform = rotation(3.14/6, -Point(1,0,0))

print(foo.intersect(bar))
print(foo.intersect(transform*bar))

This code shows that the intersections are found before bar is rotated, but not after.

release with updated numpy dependency version

Hello, we would like to use geometer in pyscript and the latest release candidate have bumped pyodide version to 0.22.1 which ships an updated 1.23.5 numpy version. Latest released geometer requires a <1.23 numpy so it cannot be installed anymore. Any chance you can release on pypi a new version please? Thanks!

Failure to transform cuboid

from geometer import *

cuboid = Cuboid(Point(0,0,0),Point(1,0,0),Point(0,1,0),Point(0,0,1))
translate = translation(1,0,0)

translate.apply(cuboid)

On my machine, this code results in an error:

Traceback (most recent call last):

File "bug.py", line 6, in
translate.apply(cuboid)
File "/usr/lib/python3.8/site-packages/geometer/transformation.py", line 133, in apply
return type(other)(other.array.dot(self.array.T))
TypeError: __init__() missing 3 required positional arguments: 'b', 'c', and 'd'

It looks to me like the problem is since type(other) is a cuboid in this instance, the cuboid constructor is called, but arguments for the polytope constructor are given.

It seems like a workaround is to cast the cuboid to a polyhedron before trying to transform it.

Sphere intersection error

I'm using Python 3.8.10 with geometer 0.2.3. This code snippet:

s0 = Sphere(Point(0, 0, 0), 1)
s1 = Sphere(Point(0.5, 0, 0), 1)
print(s0.intersect(s1))

produces

None

[clarification] What are the intended uses of this package?

Hello Jan,

I spent some time to read through the code, and the docs of geometer. I installed it & I am trying and exploring now. I wanted to ask you what is the intent for this package, and for what uses did you built it?

My love of geometry drove me towards projective geometry, and I am learning about it. My interests also lay with interactive geometry, and I was wondering if, and how I could use geometer for this purpose.

Thank you
Cheers!

Line.perpindicular() fails

version = 0.3.4
Python (windows) 3.11.1

This simple case throws TensorComputationError:

>>> PAIR = [Point(-5, 2), Point(5, 2)]
>>> ll = Line(PAIR)
>>> ll
Line([Point(-5, 2), Point(5, 2)])
>>> ll.perpendicular(Point(0,2))

Line.contains() fails

version = 0.3.4
Python (windows) 3.11.1

This simple case throws TensorComputationError:

>>> PAIR = [Point(-5, 2), Point(5, 2)]
>>> ll = Line(PAIR)
>>> ll
Line([Point(-5, 2), Point(5, 2)])
>>> ll.contains(Point(0, 6))

another numerical instability

I have run into several numerical instabilities when doing chained computations (mainly intersections). One of the problems is that the coordinates of points are not normalized automatically. Reconstructing objects from points with normalized coordinates after each intersection helps a lot. But in the following case the normalizations did not help:

a = 100.
p1 = Point(0., 0.)
p2 = Point(a,  0.)
p3 = Point(a,  a)
p4 = Point(0., a)
square = Polygon(p1,p2,p3,p4)
line1 = Line(p3,p4)
print(square.intersect(line1))

gives:

...\lib\site-packages\geometer\point.py:95: RuntimeWarning: invalid value encountered in true_divide
  result.array = result.array / np.max(np.abs(result.array), axis=axes, keepdims=True)
[Point(100.0, 100.0), Point(-0.0, 100.0)]

Ok, one can live with that warning; the result is correct. But altering the coordinates of the line points a little

EPS = 1e-6
line2 = Line(Point(a, a-EPS), Point(0, a+EPS))
print(square.intersect(line2))

gives an intersection with three points:

[Point(100.0, 99.99999899999999), Point(49.99999955908597, 100.0), Point(-0.0, 100.00000099999998)]

Here the additional code for correcting the result is a bit more involved.

Intersection of line and cylinder

Is intersection of line and cylinder implemented? I tried this:

c = Cylinder()
l = Line(Point(2, 2, 2), Point(3, 3, 3))
print(l.meet(c))

without success.

Other Backends

To use geometer for geometric computations on the GPU or for calculations involving symbolic mathematics, it would be great to have a choice of other backends like Jax and SymPy.

Since the API of Jax is mostly identical to that of NumPy, this should be an easy conversion. Execution on the GPU will probably be useful for calculations with large collections of points/lines because these require a large amount of matrix-vector-multiplications (in calls to the einsum function).

Since SymPy only contains a relatively small geometry module (only 2D) and no projective geometry module, a SymPy backend would also make sense.

Google's TensorNetwork library follows a similar approach and provides multiple backends for similar types of computation.

So for now the plan is to implement these backends:

  • NumPy
  • Jax
  • SymPy

Feedback & suggestions are welcome!

Rectangle vertex order matters

I'm not sure if it's intended but:

geometer.Rectangle(
    np.array([0., 0., 1.]),
    np.array([0., 1., 1.]),
    np.array([1., 1., 1.]),
    np.array([1., 0., 1.]),
).area
>> 1.
geometer.Rectangle(
    np.array([0., 0., 1.]),
    np.array([0., 1., 1.]),
    np.array([1., 0., 1.]),
    np.array([1., 1., 1.]),
).area
>> 0.

numerical instability

>>> from geometer import Point, dist
>>> p1 = Point(100.0, 0.0)
>>> p2 = Point(101.0, 0.0)
>>> p1 == p2
True
>>> dist(p1, p2)
0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.