Ask Your Question
1

Best way to represent a point

asked 2015-12-19 15:50:36 +0200

Neabfi gravatar image

Hello,

I have a point p1(x1, y1) and a point p2(x2, y2). For example I want p1 = 2 * p2 For the moment I store the points in lists so I have to do like: p1[0] = 2 * p2[0] p1[1] = 2 * p2[1] It's very ugly. What's the best way to do that ? Thanks in advance

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-12-19 19:59:27 +0200

vdelecroix gravatar image

You should use vectors

sage: p = vector((3,4))
sage: q = vector((0,-1))
sage: 2*p
(6, 8)
sage: p + q
(3, 3)
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-12-19 15:50:36 +0200

Seen: 212 times

Last updated: Dec 19 '15