Class JXG.Point
JXG.GeometryElement
↳ JXG.Point
Creates a new point object. Do not use this constructor to create a point. Use JXG.Board#create with
type Point, Glider, or Intersection instead.
Defined in: Point.js.
Extends
JXG.GeometryElement.
Constructor Attributes | Constructor Name and Description |
---|---|
JXG.Point(board, coordinates, attributes)
A point is the basic geometric element.
|
Field Attributes | Field Name and Description |
---|---|
If the distance of the point to one of its attractors is less
than this number the point will be a glider on this
attracting element.
|
|
List of attractor elements.
|
|
There are different point styles which differ in appearance.
|
|
If true, the infobox is shown on mouse over, else not.
|
|
Determines the size of a point.
|
|
Defines together with JXG.Point#snapSizeY the grid the point snaps on to.
|
|
Defines together with JXG.Point#snapSizeX the grid the point snaps on to.
|
|
If set to true, the point will snap to a grid defined by
JXG.Point#snapSizeX and JXG.Point#snapSizeY.
|
|
If set to true, the point will snap to the nearest point in distance of
JXG.Point#attractorDistance.
|
|
If the distance of the point to one of its attractors is at least
this number the point will be released from being a glider on the
attracting element.
|
|
This attribute was used to determined the point layout.
|
- Fields borrowed from class JXG.GeometryElement:
- addEvent, ancestors, baseElement, board, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getAttribute, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, shadow, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel
Field Attributes | Field Name and Description |
---|---|
<private> |
Coordinates of the point.
|
<private> |
Stores the groups of this point in an array of Group.
|
<private> |
Determines whether the point slides on a polygon if point is a glider.
|
<private> |
Relative position on a line if point is a glider on a line.
|
- Fields borrowed from class JXG.GeometryElement:
- addEvent, ancestors, baseElement, board, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getAttribute, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, shadow, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel
Method Attributes | Method Name and Description |
---|---|
<private> |
_anim(direction, stepCount)
Animates a glider.
|
addConstraint(terms)
Convert the point to CAS point and call update().
|
|
addTransform(el, transform)
Add transformations to this point.
|
|
Dist(point2)
Getter method for the distance to a second point, this is required for CAS-elements.
|
|
free()
Converts a glider into a free point.
|
|
A point can change its type from free point to glider
and vice versa.
|
|
Move a point to its nearest grid point.
|
|
Let a point snap to the nearest point in distance of
JXG.Point#attractorDistance.
|
|
<private> |
hasPoint(x, y)
Checks whether (x,y) is near the point.
|
makeGlider(glideObject)
Convert the point to glider and update the construction.
|
|
moveAlong(path, time, options)
Starts an animation which moves the point along a given path in given time.
|
|
moveTo(where, time, options)
Starts an animated point movement towards the given coordinates where.
|
|
All point faces can be defined with more than one name, e.g.
|
|
remove()
Remove the point from the drawing.
|
|
Sets the position of a glider relative to the defining elements of the JXG.Point#slideObject.
|
|
setPosition(method, x, y)
Sets x and y coordinate and calls the point's update() method.
|
|
setPositionByTransform(method, x, y)
TODO
|
|
setPositionDirectly(method, x, y, x, y)
Sets x and y coordinate and calls the point's update() method.
|
|
<private> |
setStyle(i)
Set the style of a point.
|
update(fromParent)
Updates the position of the point.
|
|
<private> |
Dummy function for unconstrained points or gliders.
|
<private> |
Update of glider in case of dragging the glider or setting the postion of the glider.
|
<private> |
Update of a glider in case a parent element has been updated.
|
<private> |
Calls the renderer to update the drawing.
|
Applies the transformations of the curve to JXG.Point#baseElement.
|
|
visit(where, time, options)
Starts an animated point movement towards the given coordinates where.
|
|
X()
Getter method for x, this is used by for CAS-points to access point coordinates.
|
|
<private> |
XEval()
New evaluation of the function term.
|
Y()
Getter method for y, this is used by CAS-points to access point coordinates.
|
|
<private> |
YEval()
New evaluation of the function term.
|
Z()
Getter method for z, this is used by CAS-points to access point coordinates.
|
|
<private> |
ZEval()
New evaluation of the function term.
|
- Methods borrowed from class JXG.GeometryElement:
- _set, addChild, addDescendants, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, generatePolynomial, getAttributes, getLabelAnchor, getName, getParents, getProperty, getTextAnchor, getType, hideElement, labelColor, noHighlight, normalize, off, on, prepareUpdate, resolveShortcuts, setArrow, setAttribute, setDash, setLabelText, setProperty, setStraight, showElement, triggerEventHandlers
Class Detail
JXG.Point(board, coordinates, attributes)
A point is the basic geometric element. Based on points lines and circles can be constructed which can be intersected
which in turn are points again which can be used to construct new lines, circles, polygons, etc. This class holds methods for
all kind of points like free points, gliders, and intersection points.
- Parameters:
- {string|JXG.Board} board
- The board the new point is drawn on.
- {Array} coordinates
- An array with the affine user coordinates of the point.
- {Object} attributes
- An object containing visual properties like in JXG.Options#point and JXG.Options#elements, and optional a name and a id.
- See:
- JXG.Board#generateName
- JXG.Board#addPoint
Attribute Detail
{number}
attractorDistance
If the distance of the point to one of its attractors is less
than this number the point will be a glider on this
attracting element.
If set to zero nothing happens.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- 0
{array}
attractors
List of attractor elements. If the distance of the point is less than
attractorDistance the point is made to glider of this element.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- empty
{string}
face
There are different point styles which differ in appearance.
Posssible values are
Defined in: Options.js.
Value |
---|
cross |
circle |
square |
plus |
diamond |
triangleUp |
triangleDown |
triangleLeft |
triangleRight |
Defined in: Options.js.
- See:
- JXG.Point#setStyle
- Default Value:
- circle
{Boolean}
showInfobox
If true, the infobox is shown on mouse over, else not.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- true
{number}
size
Determines the size of a point.
Means radius resp. half the width of a point (depending on the face).
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- 3
{Number}
snapSizeX
Defines together with JXG.Point#snapSizeY the grid the point snaps on to.
The point will only snap on values multiple to snapSizeX in x and snapSizeY in y direction.
If this value is equal to or less than 0, it will use the grid displayed by the major ticks
of the default ticks of the default x axes of the board.
Defined in: Options.js.
Defined in: Options.js.
- See:
- JXG.Point#snapToGrid
- JXG.Point#snapSizeY
- JXG.Board#defaultAxes
- Default Value:
- 1
{Number}
snapSizeY
Defines together with JXG.Point#snapSizeX the grid the point snaps on to.
The point will only snap on values multiple to snapSizeX in x and snapSizeY in y direction.
If this value is equal to or less than 0, it will use the grid displayed by the major ticks
of the default ticks of the default y axes of the board.
Defined in: Options.js.
Defined in: Options.js.
- See:
- JXG.Point#snapToGrid
- JXG.Point#snapSizeX
- JXG.Board#defaultAxes
- Default Value:
- 1
{Boolean}
snapToGrid
If set to true, the point will snap to a grid defined by
JXG.Point#snapSizeX and JXG.Point#snapSizeY.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- false
{Boolean}
snapToPoints
If set to true, the point will snap to the nearest point in distance of
JXG.Point#attractorDistance.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- false
{number}
snatchDistance
If the distance of the point to one of its attractors is at least
this number the point will be released from being a glider on the
attracting element.
If set to zero nothing happens.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- 0
{Number}
style
This attribute was used to determined the point layout. It was derived from GEONExT and was
replaced by JXG.Point#face and JXG.Point#size.
Defined in: Options.js.
Defined in: Options.js.
- Default Value:
- JXG.Options.point#style
Field Detail
<private>
{JXG.Coords}
coords
Coordinates of the point.
<private>
{array}
group
Stores the groups of this point in an array of Group.
- See:
- JXG.Group
<private>
{boolean}
onPolygon
Determines whether the point slides on a polygon if point is a glider.
- Default Value:
- false
<private>
{Number}
position
Relative position on a line if point is a glider on a line.
Method Detail
<private>
_anim(direction, stepCount)
Animates a glider. Is called by the browser after startAnimation is called.
- Parameters:
- {Number} direction
- The direction the glider is animated.
- {Number} stepCount
- The number of steps.
- See:
- #startAnimation
- #stopAnimation
addConstraint(terms)
Convert the point to CAS point and call update().
- Parameters:
- {Array} terms
- [[zterm], xterm, yterm] defining terms for the z, x and y coordinate.
The z-coordinate is optional and it is used for homogeneaous coordinates.
The coordinates may be either
- a JavaScript function,
- a string containing GEONExT syntax. This string will be converted into a JavaScript function here,
- a Number
- a pointer to a slider object. This will be converted into a call of the Value()-method of this slider.
- See:
- JXG.GeonextParser#geonext2JS
{JXG.Point}
addTransform(el, transform)
Add transformations to this point.
- Parameters:
- {JXG.GeometryElement} el
- TODO base element
- {JXG.Transform|Array} transform
- Either one JXG.Transform or an array of JXG.Transforms.
- Returns:
- {JXG.Point} Reference to this point object.
{Number}
Dist(point2)
Getter method for the distance to a second point, this is required for CAS-elements.
Here, function inlining seems to be worthwile (for plotting).
- Parameters:
- {JXG.Point} point2
- The point to which the distance shall be calculated.
- Returns:
- Distance in user coordinate to the given point
free()
Converts a glider into a free point.
handleAttractors()
A point can change its type from free point to glider
and vice versa. If it is given an array of attractor elements
(attribute attractors) and the attribute attractorDistance
then the pint will be made a glider if it less than attractorDistance
apart from one of its attractor elements.
If attractorDistance is equal to zero, the point stays in its
current form.
handleSnapToGrid()
Move a point to its nearest grid point.
The function uses the coords object of the point as
its actual position.
handleSnapToPoints()
Let a point snap to the nearest point in distance of
JXG.Point#attractorDistance.
The function uses the coords object of the point as
its actual position.
<private>
{boolean}
hasPoint(x, y)
Checks whether (x,y) is near the point.
- Parameters:
- {int} x
- Coordinate in x direction, screen coordinates.
- {int} y
- Coordinate in y direction, screen coordinates.
- Returns:
- True if (x,y) is near the point, False otherwise.
makeGlider(glideObject)
Convert the point to glider and update the construction.
- Parameters:
- {String|Object} glideObject
- The Object the point will be bound to.
{JXG.Point}
moveAlong(path, time, options)
Starts an animation which moves the point along a given path in given time.
- Parameters:
- {Array|function} path
- The path the point is moved on. This can be either an array of arrays containing x and y values of the points of the path, or function taking the amount of elapsed time since the animation has started and returns an array containing a x and a y value or NaN. In case of NaN the animation stops.
- {Number} time
- The time in milliseconds in which to finish the animation
- {Object} options Optional
- Optional settings for the animation:
- callback: A function that is called as soon as the animation is finished.
- Returns:
- {JXG.Point} Reference to the point.
{JXG.Point}
moveTo(where, time, options)
Starts an animated point movement towards the given coordinates where. The animation is done after time milliseconds.
If the second parameter is not given or is equal to 0, setPosition() is called, see #setPosition.
- Parameters:
- {Array} where
- Array containing the x and y coordinate of the target location.
- {Number} time Optional
- Number of milliseconds the animation should last.
- {Object} options Optional
- Optional settings for the animation:
- callback: A function that is called as soon as the animation is finished.
- effect: animation effects like speed fade in and out. possible values are '<>' for speed increase on start and slow down at the end (default) and '--' for constant speed during the whole animation.
- Returns:
- {JXG.Point} Reference to itself.
- See:
- #animate
{String}
normalizeFace(s)
All point faces can be defined with more than one name, e.g. a cross faced point can be given
by face equal to 'cross' or equal to 'x'. This method maps all possible values to fixed ones to
simplify if- and switch-clauses regarding point faces. The translation table is as follows:
Input | Output |
---|---|
cross, x | x |
circle, o | o |
square, [] | [] |
plus, + | + |
diamond, <> | <> |
triangleup, a, ^ | A |
triangledown, v | v |
triangleleft, < | < |
triangleright, > | > |
- Parameters:
- {String} s
- A string which should determine a valid point face.
- Returns:
- {String} Returns a normalized string or undefined if the given string is not a valid point face.
remove()
Remove the point from the drawing. This only removes the SVG or VML node of the point and its label from the renderer, to remove
the object completely you should use JXG.Board#removeObject.
{JXG.Point}
setGliderPosition(x)
Sets the position of a glider relative to the defining elements of the JXG.Point#slideObject.
- Parameters:
- {Number} x
- Returns:
- {JXG.Point} Reference to the point element.
setPosition(method, x, y)
Sets x and y coordinate and calls the point's update() method.
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Number} x
- x coordinate in screen/user units
- {Number} y
- y coordinate in screen/user units
setPositionByTransform(method, x, y)
TODO
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Number} x
- x coordinate in screen/user units
- {Number} y
- y coordinate in screen/user units
setPositionDirectly(method, x, y, x, y)
Sets x and y coordinate and calls the point's update() method.
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Number} x
- x coordinate in screen/user units
- {Number} y
- y coordinate in screen/user units
- {Number} x
- optional: previous x coordinate in screen/user units (ignored)
- {Number} y
- optional: previous y coordinate in screen/user units (ignored)
<private>
setStyle(i)
Set the style of a point. Used for GEONExT import and should not be used to set the point's face and size.
- Parameters:
- {Number} i
- Integer to determine the style.
update(fromParent)
Updates the position of the point.
- Parameters:
- fromParent
<private>
updateConstraint()
Dummy function for unconstrained points or gliders.
<private>
updateGlider()
Update of glider in case of dragging the glider or setting the postion of the glider.
The relative position of the glider has to be updated.
<private>
updateGliderFromParent()
Update of a glider in case a parent element has been updated. That means the
relative position of the glider stays the same.
<private>
updateRenderer()
Calls the renderer to update the drawing.
{JXG.Point}
updateTransform()
Applies the transformations of the curve to JXG.Point#baseElement.
- Returns:
- {JXG.Point} Reference to this point object.
{JXG.Point}
visit(where, time, options)
Starts an animated point movement towards the given coordinates where. After arriving at where the point moves back to where it started.
The animation is done after time milliseconds.
- Parameters:
- {Array} where
- Array containing the x and y coordinate of the target location.
- {Number} time
- Number of milliseconds the animation should last.
- {Object} options Optional
- Optional settings for the animation:
- callback: A function that is called as soon as the animation is finished.
- effect: animation effects like speed fade in and out. possible values are '<>' for speed increase on start and slow down at the end (default) and '--' for constant speed during the whole animation.
- repeat: How often this animation should be repeated (default: 1)
- Returns:
- {JXG.Point} Reference to itself.
- See:
- #animate
{Number}
X()
Getter method for x, this is used by for CAS-points to access point coordinates.
- Returns:
- User coordinate of point in x direction.
<private>
{Number}
XEval()
New evaluation of the function term.
This is required for CAS-points: Their XTerm() method is overwritten in #addConstraint
- Returns:
- User coordinate of point in x direction.
{Number}
Y()
Getter method for y, this is used by CAS-points to access point coordinates.
- Returns:
- User coordinate of point in y direction.
<private>
{Number}
YEval()
New evaluation of the function term.
This is required for CAS-points: Their YTerm() method is overwritten in #addConstraint
- Returns:
- User coordinate of point in y direction.
{Number}
Z()
Getter method for z, this is used by CAS-points to access point coordinates.
- Returns:
- User coordinate of point in z direction.
<private>
{Number}
ZEval()
New evaluation of the function term.
This is required for CAS-points: Their ZTerm() method is overwritten in #addConstraint
- Returns:
- User coordinate of point in z direction.