<commit_before>from dxfwrite import DXFEngine as dxf
import csv
import math
import pdb

########## Declaration ##########
points = []
data = []
area = 0

#Getting filename with which the file is to be saved.
filename =raw_input('Enter a new name for the file:')
drawing = dxf.drawing(filename+'.dxf')

#CSV file input.
csvfile=raw_input('Enter the name of CSV file (without extension):')
f = open(csvfile+'.csv')


# Adding csv lines to list data.
for row in csv.reader(f):
    data.append(row)


######################### Functions Defintion #########################

##### Base Drain #####
"""Creating Base drain
"""
def drawconti(data):
    for i in range(len(data) - 1):
        element1 = tuple(data[i])
        element2 =tuple(data[i+1])

        """drawing lines for base. First 10 lines in CSV contains the
        coordinates that will create the base.
        """
        if i < 9:
            drawing.add(dxf.line(element1, element2, color=7))
            points.append(element1)
        else:
            print i


""" Solving two equations simultaneously. Here (p1x, p1y) and (p2x, p2y)
are the two points of a line and (px, py) is a single known point of
second line and theta is the angle it makes with x-axis.
"""

def solve(p1x, p1y, p2x, p2y, px, py, theta):
    #m1 and m2 are the slopes of given line.
    m1 = (p1y - p2y)/(p1x - p2x)
    m2 = math.tan(theta*(math.pi)/180)

    #if both lines are parallel.
    if (m1 == m2):
        return -1

    c1 = (p2y - m1*p2x)
    c2 = (py - m2*px)
    x = (c2 - c1) / (m1 - m2)
    y = m2*x + c2
    return x, y

"""Determinent of a 2x2 matrix.
"""
def det(x1,y1,x2,y2):
    return float(x1)*float(y2)-float(x2)*float(y1)


#################### Calling Functions ####################

drawconti(data)

#pdb.set_trace() #for debugging (tracing)


theta = 180 - 63.43
theta2 = 180 - theta
print theta,theta2
""" (a1, b1) are the coordinates of the intersection points obtained by
solving the left side and similarly (a2, b2) are for the right side
intersection.
"""
if theta >= 90.45 and theta <= 114.77 and theta2 <= 89.55 and theta2 >= 65.23:
    a1, b1 = solve(-1.05, 217.05, -0.85, 217.05, -0.8465, 216.609, theta)
    a2, b2 = solve(1.05, 217.05, 0.85, 217.05, 0.8465, 216.609, theta2)
    print 'first case'
elif theta > 114.77 and theta <= 167.29 and theta2 < 65.23 and theta2 >= 12.71:
    a1, b1 = solve(-1.25, 216.7, -1.05, 217.05, -0.8465, 216.609, theta)
    a2, b2 = solve(1.25, 216.7, 1.05, 217.05, 0.8465, 216.609, theta2)
    print 'second case'
elif theta > 167.29 and theta <= 180 and theta2 < 12.71 and theta2 >=0:
    a1, b1 = solve(-1.45, 216.7, -1.25, 216.7, -0.8465, 216.609, theta)
    a2, b2 = solve(1.45, 216.7, 1.25, 216.7, 0.8465, 216.609, theta2)
    print 'third case'
else:
    print 'Invalid angle'

# Intersection points.<commit_msg>length fxn for two pts<commit_after>from dxfwrite import DXFEngine as dxf
import csv
import math
import pdb

########## Declaration ##########
points = []
data = []
area = 0

#Getting filename with which the file is to be saved.
filename =raw_input('Enter a new name for the file:')
drawing = dxf.drawing(filename+'.dxf')

#CSV file input.
csvfile=raw_input('Enter the name of CSV file (without extension):')
f = open(csvfile+'.csv')


# Adding csv lines to list data.
for row in csv.reader(f):
    data.append(row)


######################### Functions Defintion #########################

##### Base Drain #####
"""Creating Base drain
"""
def drawconti(data):
    for i in range(len(data) - 1):
        element1 = tuple(data[i])
        element2 =tuple(data[i+1])

        """drawing lines for base. First 10 lines in CSV contains the
        coordinates that will create the base.
        """
        if i < 9:
            drawing.add(dxf.line(element1, element2, color=7))
            points.append(element1)
        else:
            print i


""" Solving two equations simultaneously. Here (p1x, p1y) and (p2x, p2y)
are the two points of a line and (px, py) is a single known point of
second line and theta is the angle it makes with x-axis.
"""

def solve(p1x, p1y, p2x, p2y, px, py, theta):
    #m1 and m2 are the slopes of given line.
    m1 = (p1y - p2y)/(p1x - p2x)
    m2 = math.tan(theta*(math.pi)/180)

    #if both lines are parallel.
    if (m1 == m2):
        return -1

    c1 = (p2y - m1*p2x)
    c2 = (py - m2*px)
    x = (c2 - c1) / (m1 - m2)
    y = m2*x + c2
    return x, y

"""Determinent of a 2x2 matrix.
"""
def det(x1, y1, x2, y2):
    return float(x1)*float(y2)-float(x2)*float(y1)

"""Finding length of a line from two points
"""
def length(px1, py1, px2, py2):
    py = (py2 - py1) * (py2 - py1)
    px = (px2 - px1) * (px2 - px1)
    print 'length is ', math.sqrt(py + px)
    return math.sqrt(py + px)

#################### Calling Functions ####################

drawconti(data)

#pdb.set_trace() #for debugging (tracing)
length(-1.05, 217.05, -0.8465, 216.609)

theta = 180 - 63.43
theta2 = 180 - theta
print theta,theta2
""" (a1, b1) are the coordinates of the intersection points obtained by
solving the left side and similarly (a2, b2) are for the right side
intersection.
"""
if theta >= 90.45 and theta <= 114.77 and theta2 <= 89.55 and theta2 >= 65.23:
    a1, b1 = solve(-1.05, 217.05, -0.85, 217.05, -0.8465, 216.609, theta)
    a2, b2 = solve(1.05, 217.05, 0.85, 217.05, 0.8465, 216.609, theta2)
    print 'first case'
elif theta > 114.77 and theta <= 167.29 and theta2 < 65.23 and theta2 >= 12.71:
    a1, b1 = solve(-1.25, 216.7, -1.05, 217.05, -0.8465, 216.609, theta)
    a2, b2 = solve(1.25, 216.7, 1.05, 217.05, 0.8465, 216.609, theta2)
    print 'second case'
elif theta > 167.29 and theta <= 180 and theta2 < 12.71 and theta2 >=0:
    a1, b1 = solve(-1.45, 216.7, -1.25, 216.7, -0.8465, 216.609, theta)
    a2, b2 = solve(1.45, 216.7, 1.25, 216.7, 0.8465, 216.609, theta2)
    print 'third case'
else:
    print 'Invalid angle'

# Intersection points.
{'fraction_non_alphanumeric': 0.1763317599460553, 'fraction_numerical': 0.10536075522589346, 'mean_word_length': 2.913588390501319, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1584882', 'n_tokens_mistral': 2634, 'n_tokens_neox': 2225, 'n_words': 735}