# Geometry :

Subject: Re: [geometry] nsphere and views names
From: Barend Gehrels (barend_at_[hidden])
Date: 2013-06-23 13:32:38

Hi Adam,

On 23-6-2013 19:03, Adam Wulkiewicz wrote:
> 2013/6/23 Barend Gehrels <barend_at_[hidden] <mailto:barend_at_[hidden]>>
>
>
> What is the difference between view::as_centroid and the normal
> return_centroid? Same question for envelope. IMO all these calls
> are redundant - we have this already. What does as_bounds do?
>
>
> The functions we have converts one Geometry into another.

Not always: the centroid of the point just returns the point. A centroid
of a circle would just return its center, provided the Point-type equals
the Point-type the circle is based on.

> View preferably would store reference and provide needed data without
> conversion. And if someone wanted to convert the geometry because he
> want to reuse it somehow, he probably should use other method than view.
>
> view::as_centroid for sphere would just access center's coordinates
> using get<>(), for box it could calculate it on the fly using min and
> max coordinate, all without the conversion, and storing of additional
> Point.

OK I understand that now. That needs an additional type (e.g.
centroid_of_box) which calculates the x and y (and z) each time it is
accessed. I don't know if I would really prefer that above a one-time
calculation and extra storage of only one point...

> For any geometry using Points range, this could also be calculated on
> the fly for one Dimension, in some cases this could be preferable,
> e.g. when coordinates musn't be calculated for all dimensions.

I see.

>
> The same is true with envelope, e.g. envelope's min and max corners
> for Sphere, Point, even for Polygons could be calculated on the fly,
> there is no need to create additional Box, especially for Points.

Thanks for the clarifications. I understand it now but would never use
that - way to inefficient. Is there really need for this?

>
> As for bounds(). I'm using this kind of function in the Index. It is a
> generalization of envelope() and can calculate bounding objects of
> arbitrary type, e.g. bounding box or sphere.

The envelope does that too (calculating bounding objects of arbitrary
type) - what is exactly the difference?

Regards, Barend

Geometry list run by mateusz at loskot.net