Ask Your Question
1

Best way to represent a point

asked 2015-12-19 08:50:36 -0600

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 12:59:27 -0600

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 08:50:36 -0600

Seen: 71 times

Last updated: Dec 19 '15