Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 42c69ae9 authored by EXT José Ignacio Requeno Jarabo's avatar EXT José Ignacio Requeno Jarabo
Browse files

New mini/maxi and minimum/maximum operators in Point

New logger for Geometry
parent bf5a6de4
Pipeline #32861 canceled with stages
......@@ -106,6 +106,10 @@ class Rectangle(object):
assert greater_equal(self.max_corner, self.min_corner) or incomparables(self.min_corner, self.max_corner)
def reset(self):
self.vol = None
self.vertx = None
def __setattr__(self, name, value):
# type: (Rectangle, str, None) -> None
"""
......@@ -1061,6 +1065,31 @@ class Rectangle(object):
"""
return other.dominates_rect(self)
# Scaling functions
def scale(self, f=lambda x: x):
# type: (Rectangle, callable) -> None
"""
Function that scales the current rectangle according to a scaling function f.
Args:
self (Rectangle): The Rectangle,
f (callable): The scaling factor
Returns:
None: Current rectangle is scaled.
Example:
>>> x = (0,0)
>>> y = (1,1)
>>> r = Rectangle(x,y)
>>> def f(p):
>>> return (70-p[0], -p[1])
>>> r.scale(f)
>>> [(70.0,-1.0), (70.0,0.0)]
"""
self.min_corner = f(self.min_corner)
self.max_corner = f(self.max_corner)
# Matplot functions
def plot_2D(self, c='red', xaxe=0, yaxe=1, opacity=1.0):
# type: (Rectangle, str, int, int, float) -> patches.Rectangle
......
......@@ -491,6 +491,56 @@ class ResultSet(object):
res = ResultSet(border=border, ylow=ylow, yup=yup, xspace=xspace)
return res
# Scaling functions
def scale_xspace(self, f=lambda x: x):
# type: (ResultSet, callable) -> None
self.xspace.scale(f)
def scale_yup(self, f=lambda x: x):
# type: (ResultSet, callable) -> None
for r in self.yup:
r.scale(f)
def scale_ylow(self, f=lambda x: x):
# type: (ResultSet, callable) -> None
for r in self.ylow:
r.scale(f)
def scale_border(self, f=lambda x: x):
# type: (ResultSet, callable) -> None
for r in self.border:
r.scale(f)
def scale(self, f=lambda x: x):
# type: (ResultSet, callable) -> None
"""
Function that scales all the rectangles in the current result set according to a scaling function f.
Args:
self (ResultSet): The ResultSet,
f (callable): The scaling factor
Returns:
None: Current ResultSet is scaled.
Example:
>>> xspace = Rectangle((0.0,0.0), (1.0,1.0))
>>> ylow = [Rectangle((0.0,0.0), (0.5,0.5))]
>>> yup = [Rectangle((0.5,0.5), (1.0,1.0))]
>>> border = [Rectangle((0.0,0.5), (0.5,1.0)), Rectangle((0.5,1.0), (1.0,1.0))]
>>> rs = ResultSet(border, ylow, yup, xspace)
>>> rs.min_corner = (0.0, 0.0)
>>> def f(p):
>>> return (0.5*p[0], -p[1])
>>> rs.scale(f)
>>> rs.xspace
>>> [(0.0,-1.0), (0.5,0.0)]
"""
self.scale_yup(f)
self.scale_ylow(f)
self.scale_border(f)
# MatPlot Graphics
def _plot_space_2D(self, xaxe=0, yaxe=1, opacity=1.0):
# type: (ResultSet, int, int, float) -> list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment