Hi,
In RhinoCommon we can set domain to a surface e.g.
surface.SetDomain(0, new Interval(0, 1));
Is there a backwards operation to retrieve original domain before normalizing it?
Hi,
In RhinoCommon we can set domain to a surface e.g.
surface.SetDomain(0, new Interval(0, 1));
Is there a backwards operation to retrieve original domain before normalizing it?
I think this is what you’re looking for:
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Surface_Domain.htm
-Kevin
Nope, if a surface is already normalized, this returns [0-1].
I am wondering how the initial domain is computed.
Depending on what you want to do, you could probably just store its domain in a temporary variable, before reparametrizing it.
You should not need to normalize the domain of curves and surfaces.
I’m sure I’ve posted this before:
–
Poorly parameterized objects may not intersect and trim properly when combined with other objects. “Poorly parameterized” means the curve’s domain or the surface’s u or v spaces are tiny or huge compared to the size of the object.
When curves and surfaces are paramterized with a [0,1] domain, both the accuracy and the precision of geometric calculations like intersections and closest points are reduced, sometimes dramatically. Ideally the domain of a curve is close to it’s length and the domains of a surface is close to is average breadth in the appropriate direction.
We try to have parameterization match the length of a curve or some measure of the width of the surface. Derivative information is better if we do it this way.
–
To convert interval value to normalized parameter, use Interval.NormalizedParameterAt.
To convert normalized parameter to interval value, use Interval.ParameterAt.
– Dale
Hi @Petras_Vestartas, from the size of the surface eg. try like below:
import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
def DoSomething():
brep_id = rs.GetObject("Surface", rs.filter.surface, True, False)
if not brep_id: return
# for single faced breps only
brep = rs.coercebrep(brep_id, True)
if brep.Faces.Count != 1: return
rc, width, height = brep.Faces[0].UnderlyingSurface().GetSurfaceSize()
if rc:
interval_u = Rhino.Geometry.Interval(0, width)
interval_v = Rhino.Geometry.Interval(0, height)
brep.Faces[0].SetDomain(0, interval_u)
brep.Faces[0].SetDomain(1, interval_v)
scriptcontext.doc.Objects.Replace(brep_id, brep)
DoSomething()
it should give equal results like using _Reparameterize _Automatic
on a surface.
_
c,
@clement This Indeed answers my questions. Thank you.
Also thank you @dale I was always setting domain to 0-1 without too much thinking, which seems not be a good practice.
@diff-arch Thank you too.