Class JXG.Curve
JXG.GeometryElement
↳ JXG.Curve
Creates a new curve object. Do not use this constructor to create a curve. Use JXG.Board#create with
type Curve, or Functiongraph instead.
Defined in: curve.js.
Extends
JXG.GeometryElement.
Constructor Attributes | Constructor Name and Description |
---|---|
JXG.Curve(board, parents, attributes)
Curves are the common object for function graphs, parametric curves, polar curves, and data plots.
|
Field Attributes | Field Name and Description |
---|---|
The curveType is set in @see generateTerm and used in JXG.Curve#updateCurve.
|
|
The data points of the curve are not connected with straight lines but with bezier curves.
|
- Fields borrowed from class JXG.GeometryElement:
- _pos, addEvent, ancestors, baseElement, board, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getProperty, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, lastDragTime, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, rendNode, scalable, setProperty, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel
Field Attributes | Field Name and Description |
---|---|
Number of points on curves.
|
- Fields borrowed from class JXG.GeometryElement:
- _pos, addEvent, ancestors, baseElement, board, childElements, dash, descendants, draft, dump, elementClass, elType, eventHandlers, fillColor, fillOpacity, fixed, frozen, getProperty, hasLabel, highlight, highlighted, highlightFillColor, highlightFillOpacity, highlightStrokeColor, highlightStrokeOpacity, highlightStrokeWidth, id, isDraggable, isReal, lastDragTime, methodMap, mouseover, name, needsRegularUpdate, needsUpdate, notExistingParents, numTraces, quadraticform, removeEvent, rendNode, scalable, setProperty, shadow, snapToGrid, stdform, strokeColor, strokeOpacity, strokeWidth, subs, symbolic, trace, traceAttributes, traces, transformations, type, visible, visProp, withLabel
Method Attributes | Method Name and Description |
---|---|
addTransform(transform)
Add transformations to this curve.
|
|
Allocate points in the Coords array this.points
|
|
Check if at least one point on the curve is finite and real.
|
|
generateTerm(varname, xterm, yterm, mi, ma)
Converts the GEONExT syntax of the defining function term into JavaScript.
|
|
hasPoint(x, y, start)
Checks whether (x,y) is near the curve.
|
|
<private> |
Generate the method curve.X() in case curve.dataX is an array
and generate the method curve.Y() in case curve.dataY is an array.
|
isDistOK(dx, dy, MAXX, MAXY)
Compares the absolute value of dx with MAXX and the absolute value of dy
with MAXY.
|
|
isSegmentOutside(x0, y0, x1, y1)
Crude and cheap test if the segment defined by the two points (x0, y0) and (x1, y1) is
outside the viewport of the board.
|
|
maxX()
Gives the default value of the right bound for the curve.
|
|
minX()
Gives the default value of the left bound for the curve.
|
|
notifyParents(contentStr)
Finds dependencies in a given term and notifies the parents by adding the
dependent object to the found objects child elements.
|
|
setPosition(method, coords)
Translates the object by (x, y).
|
|
setPositionDirectly(method, coords, oldcoords)
Moves the cuvre by the difference of two coordinates.
|
|
update()
Computes for equidistant points on the x-axis the values of the function
|
|
Computes for equidistant points on the x-axis the values
of the function.
|
|
For dynamic dataplots updateCurve can be used to compute new entries
for the arrays JXG.Curve#dataX and JXG.Curve#dataY.
|
|
updateParametricCurve(mi, ma)
Updates the data points of a parametric curve.
|
|
updateParametricCurveNaive(mi, ma, len)
Updates the data points of a parametric curve.
|
|
Updates the visual contents of the curve.
|
|
Applies the transformations of the curve to the given point p.
|
|
Z(t)
Treat the curve as curve with homogeneous coordinates.
|
- Methods borrowed from class JXG.GeometryElement:
- _set, addChild, addDescendants, addRotation, animate, bounds, clearTrace, cloneToBackground, countChildren, createGradient, createLabel, draggable, generatePolynomial, getAttribute, getAttributes, getLabelAnchor, getName, getParents, getTextAnchor, getType, hideElement, labelColor, noHighlight, normalize, off, on, prepareUpdate, remove, removeChild, removeDescendants, resolveShortcuts, setArrow, setAttribute, setDash, setLabelText, showElement, triggerEventHandlers
- Events borrowed from class JXG.GeometryElement:
- attribute, attribute:<attribute><attribute>, down, drag, mousedown, mousedrag, mousemove, mouseout, mouseover, mouseup, move, out, over, touchdown, touchdrag, touchup, up
Class Detail
JXG.Curve(board, parents, attributes)
Curves are the common object for function graphs, parametric curves, polar curves, and data plots.
- Parameters:
- {String|JXG.Board} board
- The board the new curve is drawn on.
- {Array} parents
- defining terms An array with the functon terms or the data points of the curve.
- {Object} attributes
- Defines the visual appearance of the curve.
- See:
- JXG.Board#generateName
- JXG.Board#addCurve
Attribute Detail
curveType
The curveType is set in @see generateTerm and used in JXG.Curve#updateCurve.
Possible values are
Defined in: options.js.
- 'none'
- 'plot': Data plot
- 'parameter': we can not distinguish function graphs and parameter curves
- 'functiongraph': function graph
- 'polar'
- 'implicit' (not yet)
Defined in: options.js.
{Boolean}
handDrawing
The data points of the curve are not connected with straight lines but with bezier curves.
Defined in: options.js.
Defined in: options.js.
- Default Value:
- false
Field Detail
numberPoints
Number of points on curves. This value changes
between numberPointsLow and numberPointsHigh.
It is set in JXG.Curve#updateCurve.
Method Detail
{JXG.Curve}
addTransform(transform)
Add transformations to this curve.
- Parameters:
- {JXG.Transformation|Array} transform
- Either one JXG.Transformation or an array of JXG.Transformations.
- Returns:
- {JXG.Curve} Reference to the curve object.
allocatePoints()
Allocate points in the Coords array this.points
checkReal()
Check if at least one point on the curve is finite and real.
generateTerm(varname, xterm, yterm, mi, ma)
Converts the GEONExT syntax of the defining function term into JavaScript.
New methods X() and Y() for the Curve object are generated, further
new methods for minX() and maxX().
- Parameters:
- varname
- xterm
- yterm
- mi
- ma
- See:
- JXG.GeonextParser.geonext2JS.
{Boolean}
hasPoint(x, y, start)
Checks whether (x,y) is near the curve.
- Parameters:
- {Number} x
- Coordinate in x direction, screen coordinates.
- {Number} y
- Coordinate in y direction, screen coordinates.
- {Number} start
- Optional start index for search on data plots.
- Returns:
- {Boolean} True if (x,y) is near the curve, False otherwise.
<private>
{function}
interpolationFunctionFromArray(which)
Generate the method curve.X() in case curve.dataX is an array
and generate the method curve.Y() in case curve.dataY is an array.
- Parameters:
- {String} which
- Either 'X' or 'Y'
- Returns:
- {function}
{Boolean}
isDistOK(dx, dy, MAXX, MAXY)
Compares the absolute value of dx with MAXX and the absolute value of dy
with MAXY.
- Parameters:
- {Number} dx
- {Number} dy
- {Number} MAXX
- {Number} MAXY
- Returns:
- {Boolean} true, if |dx| < MAXX and |dy| < MAXY.
{Boolean}
isSegmentOutside(x0, y0, x1, y1)
Crude and cheap test if the segment defined by the two points (x0, y0) and (x1, y1) is
outside the viewport of the board. All parameters have to be given in screen coordinates.
- Parameters:
- {Number} x0
- {Number} y0
- {Number} x1
- {Number} y1
- Returns:
- {Boolean} true if the given segment is outside the visible area.
{Number}
maxX()
Gives the default value of the right bound for the curve.
May be overwritten in JXG.Curve#generateTerm.
- Returns:
- {Number} Right bound for the curve.
{Number}
minX()
Gives the default value of the left bound for the curve.
May be overwritten in JXG.Curve#generateTerm.
- Returns:
- {Number} Left bound for the curve.
notifyParents(contentStr)
Finds dependencies in a given term and notifies the parents by adding the
dependent object to the found objects child elements.
- Parameters:
- {String} contentStr
- String containing dependencies for the given object.
{JXG.Curve}
setPosition(method, coords)
Translates the object by (x, y).
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Array} coords
- array of translation vector.
- Returns:
- {JXG.Curve} Reference to the curve object.
{JXG.Curve}
setPositionDirectly(method, coords, oldcoords)
Moves the cuvre by the difference of two coordinates.
- Parameters:
- {Number} method
- The type of coordinates used here. Possible values are JXG.COORDS_BY_USER and JXG.COORDS_BY_SCREEN.
- {Array} coords
- coordinates in screen/user units
- {Array} oldcoords
- previous coordinates in screen/user units
- Returns:
- {JXG.Curve} this element
{JXG.Curve}
update()
Computes for equidistant points on the x-axis the values of the function
- Returns:
- {JXG.Curve} Reference to the curve object.
{JXG.Curve}
updateCurve()
Computes for equidistant points on the x-axis the values
of the function.
If the mousemove event triggers this update, we use only few
points. Otherwise, e.g. on mouseup, many points are used.
- Returns:
- {JXG.Curve} Reference to the curve object.
- See:
- JXG.Curve#update
updateDataArray()
For dynamic dataplots updateCurve can be used to compute new entries
for the arrays JXG.Curve#dataX and JXG.Curve#dataY. It
is used in JXG.Curve#updateCurve. Default is an empty method, can
be overwritten by the user.
{JXG.Curve}
updateParametricCurve(mi, ma)
Updates the data points of a parametric curve. This version is used if JXG.Curve#doadvancedplot is true.
- Parameters:
- {Number} mi
- Left bound of curve
- {Number} ma
- Right bound of curve
- Returns:
- {JXG.Curve} Reference to the curve object.
{JXG.Curve}
updateParametricCurveNaive(mi, ma, len)
Updates the data points of a parametric curve. This version is used if JXG.Curve#doadvancedplot is false.
- Parameters:
- {Number} mi
- Left bound of curve
- {Number} ma
- Right bound of curve
- {Number} len
- Number of data points
- Returns:
- {JXG.Curve} Reference to the curve object.
{JXG.Curve}
updateRenderer()
Updates the visual contents of the curve.
- Returns:
- {JXG.Curve} Reference to the curve object.
{JXG.Point}
updateTransform(p)
Applies the transformations of the curve to the given point p.
Before using it, JXG.Curve#updateTransformMatrix has to be called.
- Parameters:
- {JXG.Point} p
- Returns:
- {JXG.Point} The given point.
{Number}
Z(t)
Treat the curve as curve with homogeneous coordinates.
- Parameters:
- {Number} t
- A number between 0.0 and 1.0.
- Returns:
- {Number} Always 1.0