Reference manual
Modules
mv
MathVision provides a Python module called mv - this module provides an API
for accessing MathVision functionality by user's Python scripts. You can use mv module
the same way as any other Python module, by importing it:
Once the mv module is imported, you may begin using the API it provides.
import mv
Functions
| Name | Description |
|---|---|
| write(text) | Writes text to MathVision console. All output from Python scripts are redirected to this function, including Python's print, so users don't need to use this function explicitely. |
| flush() | Flushes console output buffer |
| registerImage(path) | Registers an image at path to be used by the application |
| unregisterImage(path) | Unregisters an image at path when it's not needed anymore |
| registerModel(type, path) |
Registers a model at path to be used by the application. Currently supported model types are:
|
| registerModelFromSource(type, source) | Refer to registerModel function. This function loads a model from source. |
| unregisterModel(path) | Unregisters a model at path when it's not needed anymore |
| registerObject(objectClass, packageName) | Registers an object to be used by the application. This function expects object class and package name as arguments. A typical usage of this function is: registerObject(myModule.MyObjectClass, __name__) |
| unregisterObject(objectName, packageName) | Unregisters an object when it's not needed anymore. This function expects object class name and package name as arguments. A typical usage of this function is: unregisterObject(myModule.MyObjectClass.getObjectName(), __name__) |
| registerOperator(operator) | Registers an operator to be used by the application. This function expects an operator instance as an argument. A typical usage of this function is: registerOperator(myModule.MyOperator()) |
| unregisterOperator(operatorName) | Unregisters an operator when it's not needed anymore. This function expects an operator instance as an argument. A typical usage of this function is: unregisterOperator(myModule.MyOperator.getName()) |
| getModel(modelName) getModel(object) |
When passed a string, this function returns a registered model by the name. When passed an object, this function returns a model associated with given object. |
| getObject(modelName) | Returns an instance of model with specified name |
| createObject(objectName) | Create and return a new instance of a model with specified name |
| addObject(instance, parent, name) |
Adds a given object's instance to MathVision objects list.
parent optional argument accepts an instance of another object, which (if provided) will be a parent of this object. If name argument is provided, it will be used as an object name, instead of automatically generated name. |
| removeObject(instance) | Removes an object instance |
| getViewport() | Returns a viewport size as an pyglm.vec2 object. |
Classes
Model
Represents a model used by objects.
| Name | Description |
|---|---|
| getRadius() | Calculates a radius of model's bounding sphere from geometric center of the model to farthest point |
| getPoints() | Returns a list of pyglm.vec3 vectors of all model's points |
| getMinmax() | Returns model's minimum and maximum points |
DynamicModel
Represents a dynamic model used by objects. A dynamic model is created and manipulated at will by addin code.
| Name | Description |
|---|---|
| getRadius() | Calculates a radius of model's bounding sphere from geometric center of the model to farthest point |
| getPoints() | Returns a list of pyglm.vec3 vectors of all model's points |
| getMinmax() | Returns model's minimum and maximum points |
| setPoints(points) | Set points for the model. points argument accepts a list of pyglm.vec3 vectors. |
mvutil
mvutil module provides some utility functions and classes which may aid user in creating their addins. The code of this module is provided in application files and may be freely inspected, however it's not recommended to modify this file's contents. Some of the more notable functionalities of this modules are listed here:
Functions
| Name | Description |
|---|---|
| orient(vector, target) | Rotates given vector towards specified target. Vectors accepted by this class must be pyglm.vec3. |
| hasBoundingSphere(object) | Checks if given object has getBoundingSphere function |
| getObject(list, classifier) | Returns an object from list filtered by classifier. Classifier may be object's name or callable object accepting a single parameter - the object. |
Classes
Sphere
A simple implementation of a sphere.
Properties
| Name | Description |
|---|---|
| position | Gets and sets the position of the sphere |
| radius | Gets and sets the radius of the sphere |