Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented Shape class that can construct closed 2D Figure and methods area, centroid, second_moment_of_area #14434

Open
wants to merge 11 commits into
base: master
from

Conversation

Projects
None yet
6 participants
@rushyam
Copy link
Contributor

commented Mar 8, 2018

Attributes
area
centroid
second moment of area
product moment of area

#14335

rushyam added some commits Feb 25, 2018

@rushyam rushyam changed the title implement shapes that can construct closed figure by boolean operations implemented Shape class that can construct closed 2D Figure and methods area, centroid, second_moment_of_area Mar 10, 2018

else:
vertex = Point(focus.args[0], focus.args[1] - self.p_parameter)
vertex = Point(focus.args[0], (focus.args[1] + self.directrix.p1[1])/2)

return vertex

This comment has been minimized.

Copy link
@rushyam

rushyam Mar 10, 2018

Author Contributor

Fixes #14461

@rushyam

This comment has been minimized.

Copy link
Contributor Author

commented Mar 10, 2018

(32*pi, -2048/(9*pi) + 32*pi, 0)
"""
if(self.name == 'Parabola'):

This comment has been minimized.

Copy link
@asmeurer

asmeurer Mar 21, 2018

Member

Don't use parentheses with if.


class Shape(GeometrySet):
"""
Parameters

This comment has been minimized.

Copy link
@asmeurer

asmeurer Mar 21, 2018

Member

Please add a description to the top of the docstring describing what the class is.

This comment has been minimized.

Copy link
@rushyam

rushyam Mar 23, 2018

Author Contributor

ok. I will add

"""

def __new__(cls, conic, line):
if (isinstance(conic, Circle) == 0 and isinstance(conic, Parabola) == 0 and isinstance(conic, Ellipse) == 0):

This comment has been minimized.

Copy link
@asmeurer

asmeurer Mar 21, 2018

Member

You can use if not isinstance(conic, (Circle, Parabola, Ellipse)). Don't use == 0 to compare booleans (see PEP 8).

if (isinstance(conic, Circle) == 0 and isinstance(conic, Parabola) == 0 and isinstance(conic, Ellipse) == 0):
raise TypeError('Wrong type of argument were put')

if (line.slope != 0 and line.slope != S.Infinity):

This comment has been minimized.

Copy link
@asmeurer

asmeurer Mar 21, 2018

Member

if line.slope not in {0, oo}

If the conic figure is Circle or Ellipse and if the line is vertical,
then the shape will be segment that belongs to right side of the line.
And if the line is horizontal, then the shape will be above the line.

This comment has been minimized.

Copy link
@asmeurer

asmeurer Mar 21, 2018

Member

I'm not really clear what this class is supposed to represent, but this seems confusing to me. Is there a better way to construct such shapes?

This comment has been minimized.

Copy link
@rushyam

rushyam Mar 23, 2018

Author Contributor

screenshot from 2018-03-23 17-38-31
screenshot from 2018-03-23 17-33-52

It will give the property of the shaded region and this is form by the intersection of the ellipse with vertical and horizontal lines.

This comment has been minimized.

Copy link
@rushyam

rushyam Mar 23, 2018

Author Contributor

we can form similar type of close shape using straight line and (parabola, ellipse, circle)

This comment has been minimized.

Copy link
@smichr

smichr Feb 23, 2019

Member

not really clear what this class is supposed to represent, but this seems confusing to me. Is there a better way to construct such shapes?

These might better be termed "segments" of conics (and I would prefer that to "shape" which is a much more general thing). They could perhaps be constructed by giving a line, width, and height and then another parameter that would determine (when width != height) whether the segment is for a parabola or an ellipse. But using the conic itself doesn't seem too bad.

@moorepants

This comment has been minimized.

Copy link
Member

commented Jul 28, 2018

@jashan498 Can you comment on this PR? It'd be nice to get the shapes working if we have them close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.