GithubHelp home page GithubHelp logo

pyeuclid's People

Contributors

dov avatar elfnor avatar

Watchers

 avatar

pyeuclid's Issues

cocos.euclid.Vector2.__rsub__ bug

What steps will reproduce the problem?
1. in the python interpreter do
2. import euclid
3. a = euclid.Vector2(1,1)
4. (0,0) - a

What is the expected output? What do you see instead?
(-1.0, -1.0) is expected, you get
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    (0,0)-a
  File "D:\tmp\euclid.py", line 202, in __rsub__
    return Vector2(other.x - self[0],
AttributeError: 'tuple' object has no attribute 'x'


What version of the product are you using? On what operating system?
euclid 0.31, python 2.6.1 , windows XP

Please provide any additional information below.
I think is a typo, with trivial fix (attached a svn diff against r31)


Original issue reported on code.google.com by [email protected] on 18 Apr 2009 at 8:07

Attachments:

AttributeError: Line has zero-length vector for vertical unit line segment.

What steps will reproduce the problem?
1. >>> LineSegment2(Point2(0,1), Point2(0,0)).connect(Point2(0, 0.7))
2.
3.

What is the expected output? What do you see instead?

Expect the usual line segment.

See:
 File "<stdin>", line 1, in <module>
  File "pyeuclid.py", line 1798, in connect
    return other._connect_line2(self)
  File "pyeuclid.py", line 1728, in _connect_line2
    c = _connect_point2_line2(self, other)
  File "pyeuclid.py", line 1652, in _connect_point2_line2
    L.p.y + u * L.v.y))
  File "pyeuclid.py", line 1766, in __init__
    raise AttributeError, 'Line has zero-length vector'
AttributeError: Line has zero-length vector

What version of the product are you using? On what operating system?

Latest source cut and pasted from the home page.
Ubuntu 11.04


Please provide any additional information below.

Seems to work for horizontal line segments, this one is vertical.


Original issue reported on code.google.com by [email protected] on 20 May 2012 at 11:18

Distance from point to line produces exception instead of 0.

What steps will reproduce the problem?
1. Create a line and a colinear point.
problem_point = euclid.Point2(0, 30)
problem_line = euclid.Line2(euclid.Point2(0, 0), euclid.Point2(0, 50))
2. Attempt to find the distance from the point to the line.
distance = problem_point.distance(problem_line)

What is the expected output? 
0, at least approximately.

What do you see instead?

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import euclid
>>> problem_point = euclid.Point2(0.0, 30.0)
>>> problem_line = euclid.Line2(euclid.Point2(0.0, 0.0), euclid.Point2(0.0, 50.0
))
>>> problem_point.distance(problem_line)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python 2.7.1\lib\site-packages\euclid.py", line 1589, i
n distance
    c = self.connect(other)
  File "C:\Program Files\Python 2.7.1\lib\site-packages\euclid.py", line 1713, i
n connect
    return other._connect_point2(self)
  File "C:\Program Files\Python 2.7.1\lib\site-packages\euclid.py", line 1792, i
n _connect_point2
    return _connect_point2_line2(other, self)
  File "C:\Program Files\Python 2.7.1\lib\site-packages\euclid.py", line 1652, i
n _connect_point2_line2
    L.p.y + u * L.v.y))
  File "C:\Program Files\Python 2.7.1\lib\site-packages\euclid.py", line 1757, i
n __init__
    raise AttributeError, 'Line has zero-length vector'
AttributeError: Line has zero-length vector
>>>

What version of the product are you using? On what operating system?
Unexcepted behavior exists in latest revision located at 
http://code.google.com/p/pyeuclid/source/browse/trunk/euclid.py. Tested on 
python 2.7.1 running on Windows XP.

Please provide any additional information below.

I believe the error is the result of this code here:

    return LineSegment2(P, 
                        Point2(L.p.x + u * L.v.x,
                               L.p.y + u * L.v.y))

on lines 1666-1668.

That line segment appears to be the shortest line segment between the point and 
the line, but since the point is colinear with the line, its length would be 
zero and its constructor raises an exception. The Geometry class defines 
distance on line 1604 to return 0.0 if the connection returns None, but it 
isn't prepared to handle the exception, which is therefore allowed to propagate 
to the caller.

Not sure if this is really a bug. It seems like the distance function should 
return 0 in this case.

I don't have any practice writing real test cases ... but maybe this would help.

def test():
    import euclid
    point = euclid.Point2(0.0, 30.0)
    line = euclid.Line2(euclid.Point2(0.0, 0.0),  euclid.Point2(0.0, 50.0))
    try:
        distance = point.distance(line)
    except AttributeError:
        return False
    if (distance < EPSILON):
        return True
    else:
        return False

It returns False, failure, for me with the unmodified latest code.

When I replace _connect_point2_line2 with this (added some code to catch the 
exception and return None, indicating the inability to connect):

def _connect_point2_line2(P, L):
    d = L.v.magnitude_squared()
    assert d != 0
    u = ((P.x - L.p.x) * L.v.x + \
         (P.y - L.p.y) * L.v.y) / d
    if not L._u_in(u):
        u = max(min(u, 1.0), 0.0)
    try:
        return LineSegment2(P, 
                            Point2(L.p.x + u * L.v.x,
                                   L.p.y + u * L.v.y))
    except AttributeError:
        # LineSegment2 is complaining because it's of length 0.
        return None

test() returns True.

Original issue reported on code.google.com by [email protected] on 23 May 2011 at 1:51

_connect_sphere_sphere produces incorrect results

Hi 

Thanks you very much for this module. I intend to use it as a basis to tidy up 
a bunch of 3D geometry code I've written.

I've found a typo in _connect_sphere_sphere.

What steps will reproduce the problem?

>>> from euclid import *
>>> sphA1 = Sphere(Point3(0.0, 0.0, 4.0), 2.0 )
>>> sphB = Sphere(Point3(0.0, 0.0 ,5.0), 4.0)
>>> print sphA1.connect(sphB)

What is the expected output? What do you see instead?
expect
LineSegment3(<0.00, 0.00, 2.00> to <0.00, 0.00, 1.00>)
get
LineSegment3(<0.00, 0.00, 2.00> to <0.00, 0.00, 4.00>)


What version of the product are you using? On what operating system?
Windows XP Python 2.6.5

Please provide any additional information below.
There is a typo in line 1963, with an 'x' instead of a 'z'
    return LineSegment3(Point3(A.c.x + v.x * A.r,
                               A.c.y + v.y * A.r,
                               A.c.x + v.z * A.r),

Also the closest two points on the spheres may be in either direction along v, 
the vector between the two sphere centres

See attached file for a rough go at fixing the problem.

cheers

Eleanor Howick



Original issue reported on code.google.com by [email protected] on 11 Aug 2011 at 5:31

Attachments:

Intersect Point and LineSegment

I wanted to determine if a point lay on a line segment and it seemed to be
unimplemented, at least in rev31. So I defined a function in class
LineSegment2, returning None if there is no intersection. The square root
operation is expensive so if anyone can do the same thing using only
magnitude_squared, please post it. Here is my code:

def _intersect_point2(self, Q):
    #Given self.p, self.v, Q.x, Q.y
    #Intersects iff (p_Q || v)  & p between end pts.
    if self.p == Q: #projection will be 0
        return self.p
    else:
        diffv = Q - self.p
        d = diffv.magnitude()
        s = self.v.magnitude()
        if (d==0 or s==0):
            return None
        ratio = diffv.dot(self.v) / (d*s) #arccos of this gives theta
        if ratio == 1 and d > 0 and d <= s: #collinear and between 
            return Q
        else:   
            return None

Original issue reported on code.google.com by [email protected] on 13 Apr 2010 at 2:26

Matrix's are incomplete: Perspective projection isn't working.

When you have a Matrix4 and a Vector3 like this:

Matrix4([    1.00     0.00     0.00     0.00
             0.00     1.00     0.00     0.00
             0.00     0.00     1.00     0.00
             0.00     0.00     1.00     0.00])
Vector3(20.00, 30.00, 10.00)

Then using the vector on the matrix should give you the same effect as if
you divided the vector by its z component:
Vector3(2.00, 3.00, 1.00)

If you do that now with the current euclid module nothing happens.

This is the part of the __mul__ method of the Matrix3 class that should be
changed:

elif isinstance(other, Point2):
    P = Point2(0, 0)
    P.x = A.a * B.x + A.b * B.y + A.c
    P.y = A.e * B.x + A.f * B.y + A.g
    return P
elif isinstance(other, Vector2):
    V = Vector2(0, 0)
    V.x = A.a * B.x + A.b * B.y 
    V.y = A.e * B.x + A.f * B.y 
    return V

This should be changed to:

elif isinstance(other, Point2):
    P = Point2(0, 0)
    w = A.i * B.x + A.j * B.y + A.k
    P.x = (A.a * B.x + A.b * B.y) / w + A.c
    P.y = (A.e * B.x + A.f * B.y) / w + A.g
    return P
elif isinstance(other, Vector2):
    V = Vector2(0, 0)
    w = A.i * B.x + A.j * B.y + A.k
    V.x = (A.a * B.x + A.b * B.y) / w + A.c
    V.y = (A.e * B.x + A.f * B.y) / w + A.g
    return V

The same part in the Matrix4 should be changed to this:

elif isinstance(other, Point3):
    P = Point3(0, 0, 0)
    w = A.m * B.x + A.n * B.y + A.o * B.z + A.p
    P.x = (A.a * B.x + A.b * B.y + A.c * B.z) / w + A.d
    P.y = (A.e * B.x + A.f * B.y + A.g * B.z) / w + A.h
    P.z = (A.i * B.x + A.j * B.y + A.k * B.z) / w + A.l
    return P
elif isinstance(other, Vector3):
    V = Vector3(0, 0, 0)
    w = A.m * B.x + A.n * B.y + A.o * B.z + A.p
    V.x = (A.a * B.x + A.b * B.y + A.c * B.z) / w + A.d
    V.y = (A.e * B.x + A.f * B.y + A.g * B.z) / w + A.h
    V.z = (A.i * B.x + A.j * B.y + A.k * B.z) / w + A.l
    return V

After the code is switched both vectors and points should work with all
types of transformation.
I tested it myself and I can't find anything wrong with it except for a
ZeroDivisionError that dosen't get in the way if you're doing everything
right but will appear when you make a mistake for example:

Matrix4([    1.00     0.00     0.00     0.00
             0.00     1.00     0.00     0.00
             0.00     0.00     1.00     0.00
             0.00     0.00     1.00     0.00])
Vector3(20.00, 30.00, 0.00)

This will cause the error but in normal cases you will keep the matrix like
this:
Matrix4([    1.00     0.00     0.00     0.00
             0.00     1.00     0.00     0.00
             0.00     0.00     1.00     0.00
             0.00     0.00     1.00     1.00])

Also most of this stuff I just found on wikipedia:
http://en.wikipedia.org/wiki/Transformation_matrix#Perspective_projection

Original issue reported on code.google.com by [email protected] on 15 Sep 2006 at 10:32

Quaternion interpolation not working

What steps will reproduce the problem?
q1 = Quaternion(.15,0, 0.99,0).normalized()
q2 = Quaternion(.15,0,-0.99,0).normalized()
print Quaternion.new_interpolate(q1,q2,0.0)
print Quaternion.new_interpolate(q1,q2,0.25)
print Quaternion.new_interpolate(q1,q2,0.5)
print Quaternion.new_interpolate(q1,q2,0.75)
print Quaternion.new_interpolate(q1,q2,1.0)

What is the expected output? What do you see instead?
I get the following output which does not appear to interpolate between the two 
quaternions:
Quaternion(real=0.15, imag=<0.00, -0.99, 0.00>)
Quaternion(real=0.15, imag=<0.00, -1.00, 0.00>)
Quaternion(real=0.15, imag=<0.00, -1.00, 0.00>)
Quaternion(real=0.15, imag=<0.00, -1.00, 0.00>)
Quaternion(real=0.15, imag=<0.00, -0.99, 0.00>)

This might be occurring when the angle between the two quaternions is obtuse?? 
I haven't dug into it enough yet to figure out the reason for failure.

What version of the product are you using? On what operating system?
Revision 36 on Ubuntu 10.04

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 19 Dec 2011 at 9:10

The angle method of vectors doesn't account for approximation errors.

What steps will reproduce the problem?

>>> from lib.euclid import Vector2 as v
>>> vv = v(-35069.37850906927, -10011.874589043844)
>>> tt = v(-213.6847759229285, -61.004365320446894)
>>> vv.angle(tt)

Will triggere a math domain exception, because the fraction of which 
to calculate the acos of will return 1.0000000000000001 instead of 1.0

It's enough to enclose the fraction in a `round()` to solve the issue.

Original issue reported on code.google.com by [email protected] on 27 Sep 2011 at 9:30

Suggestion for improving quaternion get_angle_axis

What steps will reproduce the problem?
q1 = Quaternion(1,0,0,0)
q2 = Quaternion(-1,0,0,0)
qe = q1.conjugated()*q2
qe.get_angle_axis()

What is the expected output? What do you see instead?
I would expect to get zero for the angle between these two quaternions (since 
they are the same). Instead I get the following result (an angle of 2*pi):
(6.2831853071795862, Vector3(1.00, 0.00, 0.00))

What version of the product are you using? On what operating system?
Revision #36 on Ubuntu 10.04. I looked at the latest source code, the 
get_angle_axis function has not changed since r36.

Please provide any additional information below.
The returned result is technically correct but I would think for most 
applications you would want the smallest rotation. I would recommend changing 
the get_angle_axis function to something more like this:

def get_angle_axis(self):
    if abs(self.w) > 1:
        self = self.normalized()
    angle = 2 * math.acos(abs(self.w))
    s = math.sqrt(1 - self.w ** 2)
    if s < 0.001:
        return angle, Vector3(1, 0, 0)
    elif self.w >= 0:
        return angle, Vector3(self.x / s, self.y / s, self.z / s)
    else:
        return angle,-Vector3(self.x / s, self.y / s, self.z / s)

Disclaimer: I haven't tested this function but it seems correct to me.

Original issue reported on code.google.com by [email protected] on 19 Dec 2011 at 7:54

Missing PyPi entry

Hi, thanks for great package. It would be convenient to have a maintained PyPi 
entry, we could use euclid as a regular dependency with setuptools, pip and 
alike. Let me offer my help with http://pypi.python.org/pypi/euclid/0.01 , I 
can upload euclid over there if you give me the access.

Original issue reported on code.google.com by [email protected] on 9 Aug 2011 at 8:32

Improvement on _use_slots wizardry

When inspecting the class hierarchy at run-time, I noticed that all inherit 
from object. Good, but... even the ones that inherit from another class also 
have 'object' listed explicitly: Point3(Vector3, Geometry, object), Ray3(Line3, 
object), and so on.

I understand this is a purely cosmetic nitpick, as it's a side product of the 
_use_slots magic that do no real harm.

But I guess I have a simple and elegant solution. On line 63, replace:

            return type.__new__(cls, name, bases + (object,), dct)

For

            return type.__new__(cls, name, bases or (object,), dct)

This way only classes that have no base will (explicitly) inherit from 'object'

Original issue reported on code.google.com by [email protected] on 6 Aug 2014 at 3:12

Quaternion interpolation for small rotational differences

The Quaternion.new_interpolate function does not interpolate small angles 
correctly. It looks like the code is written to skip interpolation altogether 
if the angle between the quaternions is too small.

        theta = math.acos(costheta)
        if abs(theta) < 0.01:
            Q.w = q2.w
            Q.x = q2.x
            Q.y = q2.y
            Q.z = q2.z
            return Q

        sintheta = math.sqrt(1.0 - costheta * costheta)
        if abs(sintheta) < 0.01:
            Q.w = (q1.w + q2.w) * 0.5
            Q.x = (q1.x + q2.x) * 0.5
            Q.y = (q1.y + q2.y) * 0.5
            Q.z = (q1.z + q2.z) * 0.5
            return Q

However for my application I require accurate interpolation and have switched 
to using a different method to do this. It seems like you would want to get rid 
of these shortcuts in favor of accuracy?

Original issue reported on code.google.com by [email protected] on 18 Nov 2013 at 4:46

Moving off google code

Since google code is going readonly on Aug 25th, it'd be good to mention on the 
wiki page where the project is hosted instead before that happens.

Original issue reported on code.google.com by [email protected] on 12 Aug 2015 at 9:16

Vector classes should raise on __hash__

>>> from euclid import Vector2
>>> s = { Vector2(1, 2) }
>>> Vector2(1, 2) in s
False

Vectors are mutable, so should be un-hashable, to prevent misleading behaviour 
in hashmap containers.

Original issue reported on code.google.com by [email protected] on 27 Aug 2010 at 2:23

Vector3.__eq__ is giving weird results.

What steps will reproduce the problem?
>>> a = Vector3(0.00, 0.00, 0.00)
>>> b = Vector3(0.00, 0.00, 0.00)
>>> a == b
True
>>> a != b
True

What version of the product are you using? On what operating system?
Python 2.5.1 on Ubuntu Fiesty
Linux xxargling 2.6.20-15-generic #2 SMP Sun Apr 15 07:36:31 UTC 2007 i686
GNU/Linux

Please provide any additional information below.
In the original code where this problem arose; computing the comparison
piece-wise (ie; a.x == b.x and a.y ...) gave the expected results.


Original issue reported on code.google.com by [email protected] on 8 Aug 2007 at 9:24

Feture request: Angles between vectors

Hello, I was interested in getting the angle between two vectors and wrote
some code to do it. Might be useful for other people.

def angle(v1, v2):
    '''Returns angle between two Vector3's.'''
    q = v1.normalized().dot(v2.normalized())
    if q < -1.0: return pi
    elif q > 1.0: return 0.0
    else: return acos(q)

Original issue reported on code.google.com by [email protected] on 4 Feb 2010 at 4:09

Matrix4.new_look_at is incomplete and gives incorrect results

Using Matrix4.new_look_at doesn't yield the expected results.

It looks like this:

    def new_look_at(cls, eye, at, up):
      z = (eye - at).normalized()
      x = up.cross(z).normalized()
      y = z.cross(x)

      m = cls.new_rotate_triple_axis(x, y, z)
      m.d, m.h, m.l = eye.x, eye.y, eye.z
      return m
    new_look_at = classmethod(new_look_at)

But should look something like this:

    def new_look_at(cls, eye, at, up):
      z = (eye - at).normalized()
      x = up.cross(z).normalized()
      y = z.cross(x)
      m = cls.new_rotate_triple_axis(x, y, z)
      m.transpose()
      m.d, m.h, m.l = -x.dot(eye), -y.dot(eye), -z.dot(eye)
      return m
    new_look_at = classmethod(new_look_at)

While translating the http://open.gl/ tutorials from C++ and SFML to Python and 
Pyglet I used pyeuclid in place for GLM, everything worked except for 
Matrix4.new_look_at , that is until I changed it like shown above.

The discussion that brought about the change can be found here: 
http://stackoverflow.com/questions/25027045/applying-glm-like-perspective-and-lo
okat-calculations-results-in-my-shape-di

Example code that doesn't work with the old method but does with the new can be 
found in 4-2.py, 5-1.py, and 5-2.py here: 
https://github.com/01AutoMonkey/open.gl-tutorials-to-pyglet/

And here is the relevant code sniped:

    eye = Vector3(1.2, 1.2, 1.2)
    at = Vector3(0.0, 0.0, 0.0)
    up = Vector3(0.0, 0.0, 1.0)
    view = Matrix4.new_look_at(eye, at, up)
    view = view[:]
    view_ctype = (GLfloat * len(view))(*view)
    uniView = glGetUniformLocation(shaderProgram, "view")
    glUniformMatrix4fv(uniView, 1, GL_FALSE, view_ctype)

Original issue reported on code.google.com by [email protected] on 15 Aug 2014 at 5:33

__slots__, performance, side-effects and modern python

In-code documentation of _use_slots says that *not* using it is "much faster 
than slots in current versions of Python (2.4 and 2.5)". To be fair, it also 
says that in future versions it might be faster.

Does that statement still hold in 2014?

In a few tests I did with python 2.7.4, using slots was consistently faster by 
~10%. All my google searches about the subject also indicate that performance 
is indeed better.

Perhaps the performance hit was due to old/new class style instead? Which 
brings me to another question: Is there any benefit in using old-style classes 
in modern python? If not, new classes should be used regardless of using slots 
or not.

It does not mean using slots is a no-brainer, win-win: not having a __dict__ 
have some subtle side-effects to classes instances. By the way: are those 
side-effects relevant to euclid? Maybe docs sh

Also, documentation says slots are 'memory efficient', it should clarify that 
'efficiency' means 'uses less memory': it deals about size/footprint. 'Memory 
Usage' is perhaps a better wording. It should also clarify that savings is 
proportional to number of *instances* created (a likely use-case when dealing 
with vectors and points)

So the real decision is not Performance VS Memory Efficiency, but (Performance 
+ Memory Usage) VS the side-effects of __slots__.

Sorry for bringing so many issues in a single bug report, but I feel they are 
all related.

Original issue reported on code.google.com by [email protected] on 6 Aug 2014 at 6:39

Intersection with Circle always includes end of LineSegment2

Using r36:

>>> from euclid import Circle, LineSegment2
>>> c = Circle(Point2(0.0, 0.0), 1.0)
>>> s = LineSegment2(Point2(-4.0, 0.0), Point2(-3.0, 0.0))
>>> s.intersect(c)
Point2(-3.00, 0.00)

Expected value is 'None' since segment does not intersect circle.

I attach suggested patch which fixes the issue (and seems not to introduce new 
ones, though is not fully tested).

Original issue reported on code.google.com by [email protected] on 7 Jun 2011 at 2:11

Attachments:

Vector Rotation (3D) and Angle Between Functions

Here's a couple functions I've used to rotate a vector about another vector and 
find the angle between two vectors  in 3 dimensions:

from math import sqrt, sin, cos, acos

def rotate(v1, v2, theta):
    """Rotate vector v1 about v2 by the angle theta in radians. The right hand rule applies."""

    # Adapted from equations published by Glenn Murray - Thanks Glenn!!!
    # http://inside.mines.edu/~gmurray/ArbitraryAxisRotation/ArbitraryAxisRotation.html
    x, y, z = v1
    u, v, w = v2
    newx = (
            (
                u*(u*x + v*y + w*z)
                + (x*(v**2 + w**2) + u*(-v*y - w*z))*cos(theta)
                + sqrt(u**2 + v**2 + w**2)*(-w*y + v*z)*sin(theta)
            )
            / (u**2 + v**2 + w**2)
        )
    newy = (
            (
                v*(u*x + v*y + w*z)
                + (y*(u**2 + w**2) + v*(-u*x - w*z))*cos(theta)
                + sqrt(u**2 + v**2 + w**2)*(w*x - u*z)*sin(theta)
            )
            / (u**2 + v**2 + w**2)
        )
    newz = (
            (
                w*(u*x + v*y + w*z)
                + (z*(u**2 + v**2) + w*(-u*x - v*y))*cos(theta)
                + sqrt(u**2 + v**2 + w**2)*(-v*x + u*y)*sin(theta)
            )
            / (u**2 + v**2 + w**2)
        )
    return vector([newx,newy,newz])


def angle(v1, v2):
    """Calculate the angle between vectors v1 and v2 => radians"""
    return acos(dotproduct(v1, v2) / (v1.mag*v2.mag))


These are from my own vector class, but should drop into yours without much 
trouble. Anyways, thought you might be interested. You can find the whole class 
at http://thefekete.net/gitweb/?p=python/robotarm.git;a=blob;f=pyVec.py

BTW, I'm new to google code and couldn't find a way to message the maintainers 
or commit a patch, so I'm dumping this here...


-dan

Original issue reported on code.google.com by [email protected] on 9 Dec 2010 at 5:44

Point3.connect returns nothing

What steps will reproduce the problem?
1. p0=Point3(0,0,0)
2. p1=Point3(1,1,1)
3. p0.connect(p1)

What is the expected output? What do you see instead?
LineSegment3(<0.00, 0.00, 0.00> to <1.00, 1.00, 1.00>).
None.

What version of the product are you using? On what operating system?


Please provide any additional information below.
Just add a 'return' at the beginning of the line 'other._connect_point3(self)'

Original issue reported on code.google.com by [email protected] on 14 Feb 2008 at 4:26

Vector summation suggestion

What steps will reproduce the problem?
a = Vector3(1.0,2.0,3.0)
b = a
a += Vector3(0.1,0.1,0.1)
print b

What is the expected output? What do you see instead?
I would expect the output to be Vector3(1.0,2.0,3.0)
However since b is a shallow copy of a it produces Vector3(1.1,2.1,3.1)

This has introduced some subtle bugs into my code, I would suggest making:
a += Vector3(0.1,0.1,0.1)
Function the same as:
a = a + Vector3(0.1,0.1,0.1)

Not a big deal either way you end up going with it, just a suggestion for 
improving things.

Original issue reported on code.google.com by [email protected] on 13 Nov 2013 at 7:07

2D Tengential Intersections Cause AssertionErrors

Intersecting a circle with Line2 (2D line) along a tangent causes an
AssertionError when constructing the resultant Line2.  The documentation
states that tangential cases will result in a zero length line (start and
end points the same), but the Line2 class checks for this and throws an
assertion.

Example:
>>> from euclid import *
>>> c = Circle(Point2(0.0, 0.0), 1.0)
>>> l = Line2(Point2(0.0, 1.0), Point2(1.0, 1.0))
>>> l.intersect(c)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "euclid.py", line 1602, in intersect
    return other._intersect_line2(self)
  File "euclid.py", line 1679, in _intersect_line2
    return _intersect_line2_circle(other, self)
  File "euclid.py", line 1463, in _intersect_line2_circle
    L.p.y + u2 * L.v.y))
  File "euclid.py", line 1579, in __init__
    raise AttributeError, 'Line has zero-length vector'
AttributeError: Line has zero-length vector

I'm not sure if I should expect a zero length line segment
(LineSegment2(<0.00, 1.00> to <0.00, 1.00>)) which could cause problems if
you assume that all line segments have length or a Point2 which could cause
problems if (Point2(0.00, 0.00)) you assume that all intersections return
LineSegment2 classes.

Versions tested:
python 2.5.1 and 2.6
euclid.py (unversioned from google-code page.  MD5:
0e98208edc78221be8ec23ac85960ee7)
Ubuntu 7.0.4 (older version)

Original issue reported on code.google.com by [email protected] on 19 Jan 2009 at 10:54

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.