예제 #1
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)
예제 #2
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)
예제 #3
0
screen.fill((255, 255, 255))

#"Infinate line"

pygame.draw.line(screen, (0, 0, 0), (-1, 400), (601, 400), 2)

#key points

d = (453, 563)
c = (300, 350)
distCD = Math.distance(d[0], d[1], c[0], c[1])

h = (c[0], 400)
distCH = h[1] - c[1]
distCE = Math.pythagac(distCH, distCD)
e = (c[0] + distCE, 400)
g = (c[0] - distCE, 400)

#circle, and perpendicular line

pygame.draw.circle(screen, (0, 0, 0), c, distCD, 2)
pygame.draw.line(screen, (0, 0, 0), c, (c[0], 400), 2)

#lines going from C to the point where the circle touches the the line

pygame.draw.line(screen, (0, 0, 0), c, e, 2)
pygame.draw.line(screen, (0, 0, 0), c, g, 2)

pygame.display.flip()
예제 #4
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()
예제 #5
0
from euclidMath import Math
pygame.init()

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

Math = Math()


# To bisect a given rectilineal angle

a = (400, 200)
b = (678, 449)
c = (a[0]-b[0]+a[0], 449)

distBC = Math.distance(c[0], c[1], b[0], b[1])
sqrtisgay = Math.pythagac(distBC/2, distBC)

d = (a[0], sqrtisgay + b[1])

# screen fill

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

# Triangle cunstruction

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

# prop 2 on line bc
예제 #6
0
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)

# Bisecting the straight line.

pygame.draw.line(screen, (0, 0, 0), (Math.avg(a[0], b[0]), a[1]),
                 (Math.avg(a[0], b[0]), a[1] - Math.pythagac(dist / 2, dist)),
                 2)
pygame.display.flip()

input()