getx()

Returns the horizontal coordinate of the agent’s site for a given place, or of the agent itself.

Synopsis

getx()
getx(place_name)

Description

This function returns the horizontal (x) coordinate of the agent itself if no argument is given. Otherwise it returns the horizontal coordinate of the agent’s site for the given place name. For example, getx(Workplace) returns the horizontal coordinate of the agent’s specific Workplace site.

The given coordinate is the distance in meters from the western edge of the simulation area, as defined by the locations declared in the simulation block for the program.

Parameters

place_name

The name of a place that the agent can visit.

Returns

With no argument, this returns the x-coordinate of the agent itself as a floating point number.

If place_name is given, then the x-coordinate of the agent’s site for this place is returned.

Examples

The following example retrieves the x-coordinate of the current agent’s household.

getx(Household)

Errors

If the current agent is not a member of the given place, then an error will occur. For example, it is an error to call getx(School) if the current agent does not attend a school.

See Also

gety(), latitude(), longitude()