Python assignment. Estimating overlap between Ellipses using Monte Carlo Simulation

1 answer below »
Python assignment. Estimating overlap between Ellipses using Monte Carlo Simulation
Answered Same DayFeb 28, 2021

Answer To: Python assignment. Estimating overlap between Ellipses using Monte Carlo Simulation

Amit answered on Feb 28 2021
142 Votes
Title of the assignment:
Student’s name:
Student ID:
Professor’s name:
Course title:
Date: 3/3/2020
Table of Contents
1.    Structure chart    3
2.    Implementation    3
3.    Unit testing    8
1. Structure chart
The developed structure chart for this ellipse problem b
ased on Monte Carlo simulation is presented underneath:
2. Implementation
Ellipse.py:
#OverlappingEllipses
import math
from Point import ClsPoint
class ClsEllipse:
def _init__(self,x1=0, y1=0, x2=0, y2=0, w=1):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.w = w
self.F1 = ClsPoint(self.x1,self.y1)
self.F2 = ClsPoint(self.x2,self.y2)
# default constructor
def __init__(self):
self.x1 = 0
self.y1 = 0
self.x2 = 0
self.y2 = 0
self.w = 0
def set_x1(self, x1):
#set x coordinate of point to xcoordinate
self.x1 = x1
# getter method
def get_x1(self):
return self.x1
def set_x2(self, x2):
#set x coordinate of point to xcoordinate
self.x2 = x2
# getter method
def get_x2(self):
return self.x2
def set_w(self, w):
#set x coordinate of point to xcoordinate
self.w = w
# getter method
def get_w(self):
return self.w
def set_F1(self):
self.F1 = ClsPoint(self.x1,self.y1)
def set_F2(self):
self.F2 = ClsPoint(self.x2,self.y2)
def get_F1(self):
return self.F1
def get_F2(self):
return self.F2
def get_SemiMajor(self):
#calculates and returns the lenght of the semi major axis
self.semiMajor = self.F1.distance(self.F2)*.5 + (self.w - self.F1.distance(self.F2))*.5
#half the d between F1F2 plus half w-d
return self.semiMajor
def get_SemiMinor(self):
self.semiMinor = ( (0.5*self.w)**2 - ( (0.5*self.F1.distance(self.F2) )**2) )**0.5
#using geometry to solve for semiminor
return self.semiMinor
def isPointInside(self, other):
'determines whether a given point is inside the boundary of the ellipse'
if self.F1.distance(other) + self.F2.distance(other) < self.w: #if the distance to the point is less than to a point on the boundary, then it is inside
return True
def get_Area(self):
'calculate the area of the Ellipse'
semiMajor = self.getSemiMajor()
semiMinor = self.getSemiMinor()
return math.pi*semiMajor*semiMinor
def get_Circum(self):
'circumference of the Ellipse using Ramanujan approximation formula'
semiMajor =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here