gama.old icon indicating copy to clipboard operation
gama.old copied to clipboard

points_on and points_in on a 3D shape should give points with a Z <>0

Open dphilippon opened this issue 8 years ago • 4 comments

Steps to reproduce

  1. Try the following model
global
{
	geometry shape<-cube(100#m); //Could be Sphere(100) too
	
	init
	{
		create daisy number:100
		{
			location<-one_of(points_on(world.shape,2));
			type<-"black";
			color<-#black;
		}
	}
}

species daisy
{
	string type;
	rgb color;
	aspect default
	{
		draw circle(2) color:color;
	}
}
experiment test type:gui
{
	output
	{
		display map type:opengl
		{
			graphics "exampl"
			{
				draw world.shape color:#grey;
			}
			species daisy aspect:default;
		}
	}
}
  1. You can see in the init section that i'm trying to put the daisy agents all over the shape of the world.

Expected behavior

The agents of daisy species should be on the shape of the world (ie on the sphere).

Actual behavior

They are only on the plan resulting from the intersection of the shape and the X,Y,0 plan (there is no agents with a Z <> 0 while the shape is a 3D shape) whereas it should have some agents everywhere on the shape, not only on this plan. example

System and version

All versions

dphilippon avatar Nov 26 '16 03:11 dphilippon

Hi,

There is two issues here:

  1. The points_on and any_location_in operators work only for 2D shape
  2. The built-in geometries (cube, sphere....) are not real 3D geometries, but 2D geometries with a specific attribute (depth, radius....), so the list of points of these geometries corresponds only to the points on the 2D geometry.

I have pushed 2 commits to partly solve the first points. More precisely, points_on is now working for 3D shapes and the any_location_in for 3D points/LineString (but not for 3D polygons as it is far more complex to manage).

Here an model example:

model points3D
global
{
	geometry the_geom<- (square(100) rotated_by (40, {1,0,0}));
	
	init
	{
		list<point> pts <- points_on(the_geom,10);
		create daisy number: length(pts)
		{
			color<-#red;
			location <- pts[int(self)];
		}
		create daisy number:20
		{
			color<-#green;
			location <- any_location_in(the_geom.contour);
		}
	}
}

species daisy
{
	rgb color;
	aspect default
	{
		draw sphere(1) color:color;
	}
}
experiment test type:gui
{
	output
	{
		display map type:opengl
		{
			graphics "example" transparency: 0.5
			{
				draw the_geom color:#grey;
			}
			species daisy aspect:default;
		}
	}
}

ptaillandier avatar Nov 26 '16 11:11 ptaillandier

It could be possible in theory (since we do it for rendering in OpenGL, taking all the faces into account as well as the rotation in 3D) to easily compute all the points_in and points_on a shape with a height (like cube, sphere, etc.). However, I foresee some serious consistency problems, like for example the fact that a point_in an elevated geometry will not be considered inside this geometry (as this operator only operates in 2D...).

AlexisDrogoul avatar Feb 27 '17 19:02 AlexisDrogoul

Subsumed by #2206

AlexisDrogoul avatar Jul 12 '17 07:07 AlexisDrogoul

Reopening this issue for the next round of development on GAMA 2.0

AlexisDrogoul avatar Feb 20 '22 04:02 AlexisDrogoul