API Docs for: 0.99.4
Show:

JXG.Coords Class

Defined in: src/base/coords.js:54
Module: JXG

This is the Coordinates class. Constructs a new Coordinates object. All members a coordinate has to provide are defined here.

Constructor

JXG.Coords

(
  • method
  • coordinates
  • board
  • [emitter=true]
)

Parameters:

  • method Number

    The type of coordinates given by the user. Accepted values are COORDS_BY_SCREEN and COORDS_BY_USER.

  • coordinates Array

    An array of affine coordinates.

  • board JXG.Board

    A reference to a board.

  • [emitter=true] Boolean optional

Methods

copy

(
  • obj
  • offset
)
Array private

Copy array, either JXG.Coords.srcCoords or JXG.Coords.usrCoords Uses slice() in case of standard arrays and set() in case of typed arrays.

Parameters:

  • obj Array

    Either JXG.Coords.srcCoords or JXG.Coords.usrCoords

  • offset Number

    Offset, defaults to 0 if not given

Returns:

Array:

Returns copy of the coords array either as standard array or as typed array.

distance

(
  • coord_type
  • coordinates
)
Number

Calculate distance of one point to another either in screen view or in user view.

Parameters:

  • coord_type Number

    The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.

  • coordinates JXG.Coords

    The JXG.Coords object to which the distance is calculated.

Returns:

Number:

The distance between the two coordinates.

normalizeUsrCoords

() private chainable

Normalize homogeneous coordinates

screen2usr

() private chainable

Compute user coordinates out of given screen coordinates.

setCoordinates

(
  • coord_type
  • coordinates
  • [doRound=true]
  • [noevent=false]
)
JXG.Coords chainable

Set coordinates by either user coordinates or screen coordinates and recalculate the other one.

Parameters:

  • coord_type Number

    The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and COORDS_BY_SCREEN.

  • coordinates Array

    An array of affine coordinates the Coords object is set to.

  • [doRound=true] Boolean optional

    flag If true or null round the coordinates in usr2screen. This is used in smooth curve plotting. The IE needs rounded coordinates. If doRound==false we have to round in updatePathString.

  • [noevent=false] Boolean optional

Returns:

JXG.Coords:

Reference to the coords object.

usr2screen

(
  • doRound
)
private chainable

Compute screen coordinates out of given user coordinates.

Parameters:

  • doRound Boolean

    Force rounding of the pixel values to the next integer. This is necessary for old IE versions.

Properties

board

JXG.Board

Stores the board the object is used on.

emitter

Boolean

If true, this coordinates object will emit update events every time the coordinates are set.

Default: true

licenseText

String

The small gray version indicator in the top left corner of every JSXGraph board (if showCopyright is not set to false on board creation).

scrCoords

Array

Stores coordinates for screen view as homogeneous coordinates. The values are pixels.

usrCoords

Array

Stores coordinates for user view as homogeneous coordinates.

version

String

Represents the currently used JSXGraph version.

Events

update

Triggered whenever the coordinates change.

Event Payload:

  • ou Array

    Old user coordinates

  • os Array

    Old screen coordinates