Ejemplo n.º 1
0
screen = pygame.display.set_mode((600, 600))

Math = Math()

# To draw a straight line at right angles to a given sdtraight line from a given point on it.

a = (0, 400)
b = (600, 400)
c = (300, 400)
d = (100, 400)
e = (500, 400)

dist = Math.distance(d[0], d[1], e[0], e[1])

f = (Math.avg(d[0], e[0]), d[1] - Math.pythagac(dist / 2, dist))

# Fill the screen with white.

screen.fill((255, 255, 255))

# Let AB be the given straight line, and C the given point on it.

pygame.draw.line(screen, (0, 0, 0), a, b, 2)

# Let a point D be taken at random on AC; let Ce be made equal to CD; on DE let the equilater triangle FDE be constructed, and let FC be joined.

pygame.draw.circle(screen, (0, 0, 0), c, Math.distance(d[0], 0, c[0], 0), 1)

pygame.draw.line(screen, (0, 0, 0), d, f, 2)
pygame.draw.line(screen, (0, 0, 0), e, f, 2)
Ejemplo n.º 2
0
from pygame.locals import *
from euclidMath import Math
pygame.init()

screen = pygame.display.set_mode((800, 800))

Math = Math()

# To place at a given point a straight line euqal to a given straight line.

a = (300, 420)
b = (420, 420)
c = (269, 242)
distAB = Math.distance(a[0], a[1], b[0], b[1])
distBC = Math.distance(c[0], c[1], b[0], b[1])
d = (Math.avg(a[0], b[0]), a[1] - Math.pythagac(distAB / 2, distAB))
distDB = Math.distance(d[0], d[1], b[0], b[1])

# Fill screen with white.

screen.fill((255, 255, 255))

# Let A be the given point, and BC the given straight line.

pygame.draw.circle(screen, (0, 0, 0), a, 2)
pygame.draw.line(screen, (0, 0, 0), b, c, 2)

# Thus it is required to place at the point A a straight line equal to the given straight line BC.
# From the point A to the point B let the straight line AB be joined; and on it let the equilateral triangle DAB be constructed.

pygame.draw.line(screen, (0, 0, 0), a, b, 1)
Ejemplo n.º 3
0
screen = pygame.display.set_mode((600, 600))

Math = Math()

# On a given finite straight line to construct an equilateral triangle.

a = (200, 400)
b = (400, 400)

dist = Math.distance(a[0], a[1], b[0], b[1])

# Fill screen with white
screen.fill((255, 255, 255))

# Let AB be the given finite straight line.
pygame.draw.line(screen, (0, 0, 0), a, b, 2)

# With centre A and sistance AB let the circle BCD be described.
pygame.draw.circle(screen, (0, 0, 0), a, dist, 1)

# With center B and distance BA let the circle ACE be described.
pygame.draw.circle(screen, (0, 0, 0), b, dist, 1)

# From the point C, in which the circles cut one another, to the points A, B let the straight lines CA, CB be joined.
pygame.draw.line(screen, (0, 0, 0), a, (Math.avg(a[0], b[0]), a[1] - Math.pythagac(dist/2, dist)), 2)
pygame.draw.line(screen, (0, 0, 0), b, (Math.avg(a[0], b[0]), a[1] - Math.pythagac(dist/2, dist)), 2)

pygame.display.flip()

input()