Class: HyperSphere

HyperSphere~HyperSphere(options, classSettingsopt)

Base class for n dimensional hypersphere. Extends MyObject.

Constructor

new HyperSphere(options, classSettingsopt)

Base class for n dimensional hypersphere.
Parameters:
Name Type Attributes Description
options Options See Options.
classSettings object <optional>
HyperSphere class settings.
Properties
Name Type Attributes Default Description
intersection object <optional>
HyperSphere intersection.
	For Circle intersector is line.
	For Sphere intersector is plane.
	For HyperSphere intersector is sphere.
Properties
Name Type Attributes Default Description
position float <optional>
0.0 Position of the intersector.
	For Circle position is Y coordinate of the intersection line.
	For Sphere position is Z coordinate of the intersection plane.
	For HyperSphere position is radius of the intersection sphere.
color number | string <optional>
0x0000FF Color of the intersector. Example: 'red'.
projectParams object <optional>
Parameters of project the hypersphere onto the canvas.
Properties
Name Type Attributes Default Description
scene THREE.Scene THREE.Scene
params object <optional>
{} The following parameters are available
Properties
Name Type Attributes Default Description
center object <optional>
{x: 0.0, y: 0.0, z: 0.0} center of the hypersphere
Properties
Name Type Attributes Default Description
x float <optional>
0.0 X axis of the center
y float <optional>
0.0 Y axis of the center
z float <optional>
0.0 Z axis of the center
r float <optional>
1.0 HyperSphere radius.
edges boolean | object <optional>
{} HyperSphere edges
	false - Doesn't create edges to reduce the creation time of the hypersphere
Properties
Name Type Attributes Default Description
project boolean <optional>
true false - Doesn't project edges onto canvas
creationMethod enum <optional>
edgesCreationMethod.Random method for creating edges. See edgesCreationMethod
onSelectScene function <optional>
Callback function that called after Player time was changed.
parameter hyperSphere HyperSphere object.
parameter timeId Player index.
parameter t current time.
Also see onSelectScene type definition.
settings object <optional>
The following settings are available
Properties
Name Type Attributes Description
object object <optional>
HyperSphere object.
Properties
Name Type Attributes Default Description
name String <optional>
name of hypersphere.
color String | number <optional>
'lime' color of edges or vertices.
String - color name. See list of available color names in the _colorKeywords object in the Color.js file.
number - color Hex triplet. Example: 0x0000ff - blue color.
Default color is lime for Circle and Sphere.
Default color of vertice of the Hypersphere3D is depends from the altitude angle of the vertice according the options.palette parameter.
See classSettings.settings.object.geometry.angles for details. For example if options.palette is MyThree.ColorPicker.paletteIndexes.BGYW, then:
Vertice AltitudeVertice Color
0white
π / 2lime
πblue
MyThree.ColorPicker.paletteIndexes.BGYW palette parameter is default. Note: You can define color of the each vertice separately in the classSettings.settings.object.geometry.colors parameter.
geometry object <optional>
HyperSphere geometry.
Properties
Name Type Attributes Description
angles array | object <optional>
n-dimensional hypersphere vertice angles.
array - array of vertex angles.
	Every item of array is n-dimensional array of vertex angles.
	
	All the vertices of the Circle form a circle.
	For Circle every vertice is array of one angle.
		Vertex angle is the longitude of the circle of the hypersphere in the range from - π to π.
		Vertex angle is angle of rotation around of Z axis in 3D space.
		Angle is begin from X = 0, Y = 1.
		Every vertex is [
				Math.cos(θ),//x
				Math.sin(θ)//y
			] array. θ is vertex angle.
		Example of Circle with three vertices is triangle:
		classSettings.settings.object.geometry.angles: angles: [
			[],                 //vertice[0] = [0                   ,1]
			[Math.PI * 2 / 3],  //vertice[1] = [0.8660254037844387	,-0.4999999999999998]
			[- Math.PI * 2 / 3] //vertice[2] = [-0.8660254037844387	,-0.4999999999999998]
		],
		
	All the vertices of the Sphere form a sphere.
	For Sphere every vertice is array of two angles.
		The first vertex angle is the latitude of the sphere of the hypersphere in the range from - π / 2 to π / 2.
		Zero latitude is located at the equator.
		
		The second vertex angle is the longitude of the sphere of the hypersphere in the range from - π to π.
		The second vertex angle is angle of rotation of the cross section around of Y axis.
		
		Example of Sphere with 4 vertices is pyramid:
		classSettings.settings.object.geometry.angles: [
		
			[ Math.PI / 2,  0                  ],//vertice[0] = [ 0                 , 1  , 0   ]
			[-Math.PI / 6,  Math.PI * 2 * 0 / 3],//vertice[1] = [-0.8660254037844387,-0.5, 0   ]
			[-Math.PI / 6,  Math.PI * 2 * 1 / 3],//vertice[2] = [ 0.4330127018922192,-0.5,-0.75]
			[-Math.PI / 6, -Math.PI * 2 * 1 / 3,//vertice[3] = [ 0.4330127018922195,-0.5, 0.75]
			
		],
		
	All the vertices of the HyperSphere3D form a hypersphere.
	For HyperSphere3D every vertice is array of three angles.
		The first vertex angle is the altitude of the hypersphere of the hypersphere in the range from 0 to π / 2.
		Zero altitude is located at the center of the hypersphere.
		
		The second vertex angle is the latitude of the hypersphere of the hypersphere in the range from - π / 2 to π / 2.
		Zero latitude is located at the equator.
		
		The third vertex angle is the longitude of the hypersphere of the hypersphere in the range from - π to π.
		The third vertex angle is angle of rotation of the cross section around of Y axis.
		
		Example of HyperSphere with 5 vertices is pentahedroid:
		classSettings.settings.object.geometry.angles: [
			[],
			[Math.PI / 2, Math.PI / 2],
			[
				  Math.PI / 2,//Altitude
				- Math.PI / 6,//Latitude
				  Math.PI * 0,//Longitude
			],
			[Math.PI / 2, - Math.PI / 6,   Math.PI * 2 * 1 / 3],
			[Math.PI / 2, - Math.PI / 6, - Math.PI * 2 * 1 / 3],
			],
object - see below:
Properties
Name Type Attributes Default Description
count number <optional>
3|4|5 Count of vertices with random position.
Default values:
	3 for Circle - triangle.
	4 for Sphere - pyramid.
	5 for HyperSphere3D - pentahedroid.
times array <optional>
array of vertices angles for different player Player times. See angles above.
See Player.onSelectScene for details.
Every item of the array is array of vertices angles for current Player time.
times have priority before angles.
colors array <optional>
array of colors of vertices.
Color of the each vertice is group of three (RGB) items of the colors array in range from 0 to 1. See THREE.Color for details.
Example:
[
	1, 0, 0,//First vertice is red.
	0, 1, 0,//Second vertice green.
	0, 0, 1,//Third vertice blue.
]
Note: Color of vertice is defined in the classSettings.settings.object.color parameter if it not exists in the colors array.
opacity array <optional>
array of opacities of each vertice. Each item of array is float value in the range of 0.0 - 1.0 indicating how transparent the material is. A value of 0.0 indicates fully transparent, 1.0 is fully opaque.
indices object <optional>
Array of indices of edges of hypersphere.
Properties
Name Type Attributes Description
edges array | object <optional>
HyperSphere edges.
array - array of edges.
	Every edge is array of indices of vertices from
	classSettings.settings.object.geometry.position
	Example: [[0,1], [1,2], [2,0]],//triangle
object - see below:
Properties
Name Type Attributes Default Description
count number <optional>
3 edges count.
debug boolean | object <optional>
false Debug mode.
	true - Diagnoses your code and display detected errors to console.
	object - Diagnoses your code and display detected errors to console.
Properties
Name Type Attributes Default Description
probabilityDensity boolean | Array <optional>
[] Probability density of distribution of vertices over the surface of the hypersphere.
	false - do not calculate probability density.
	[] - calculate probability density.
testVertice boolean <optional>
true
Test of converting of the vertice coordinates from Cartesian Coordinates to Polar Coordinates
and Polar Coordinates to Cartesian Coordinates
and display detected errors to console.
middleVertice boolean <optional>
true Middle vertice log.
log boolean <optional>
true Vertices and edges log.
edges boolean <optional>
true Edges log. Have effect if log = true only
continue function <optional>
Callback function that called after hypersphere edges was created.
boRemove boolean <optional>
false - do not delete the previous hypersphere while projecting a new hypersphere on scene.
boGui boolean <optional>
false - do not include hypersphere GUI.
overriddenProperties object <optional>
Overridden properties. The following properties can be override:
Properties
Name Type Attributes Description
oppositeVertice function <optional>
Returns the opposite vertice.
parameter oppositeAngleId. Opposite vertice identifier.
parameter timeId. Player index is current time identifier.
position Array <optional>
Returns an array of vertice positions.
position0 Array <optional>
Returns an array of vertice positions for the Player's start time. See settings.options.playerOptions.min of the Player.
updateVertices function <optional>
Update vertices.
parameter vertices. Array of new vertices angles.
vertices function <optional>
Returns an empty array of vertices.
r function <optional>
Returns a hypersphere radius.
parameter timeId. Player index is time identifier.
pushMiddleVertice function <optional>
pushes a middle vertice into time angles array.
parameter timeId. Player index is time identifier.
parameter middleVertice. Array of the middle vertice angles to push.
angles function <optional>
Returns a vertice angles array.
parameter anglesId. Vertice identifier.
parameter timeId. Player index is time identifier.
verticeAngles function <optional>
Returns a vertice angles.
parameter anglesCur. Array of the vertice angles.
parameter verticeId. Vertice index.
verticeText function <optional>
Returns a vertice text if user is move mouse over vertice.
parameter intersection.
parameter text. Callback function, what returns a vertice text.
text function <optional>
Returns a part of the vertice text.
Source:

Extends

  • MyObject

Members

angles

get hyper sphere angles. See classSettings.settings.object.geometry.angles parameter of the hyperSphere constructor.
Source:

defaultColor

get default color is 'lime'
Source:

(static) ND

ND
Source:

(static) edgesCreationMethod

Enums a methods for creating edges:
Random: every vertice of the edge have random position.
NearestVertice: Vertices of the edge have nearest position.
Source:

Methods

Test()

Writes a console error, if any vertices angle is out of the angles range. Normalizes a vertices angle to available range, if out of the angles range is occures.
Writes a console error, if identifier of any edge of the vertices is incorrect.
Source:

TestVertice(vertice, strVerticeId)

Writes a console error, if vertice edges count is incorrect.
Parameters:
Name Type Description
vertice object vertice for testing
strVerticeId string name of the vertice Id
Source:

angles2Vertice(anglesId, timeId)

Converts a vertice angles to vertice position.
Parameters:
Name Type Description
anglesId number | array
number: vertice id
array: array of the vertice angles
timeId number player time id
Source:
Returns:
Vertice position.

logHyperSphere()

Writes to console an important information about hyper sphere, that can help you for debugging.
Source:

name()

Base method that returns a name of the hyper sphere in the child classes.
Source:
Returns:
a console error if your call this method directly.

normalizeVerticeAngles(verticeAngles)

Normalizes a vertices angles to available range, if out of the angles range is occures.
Parameters:
Name Type Description
verticeAngles array vertice angles
Source:
Returns:
Normalized a vertices angles.

project(scene, paramsopt)

Projects the hypersphere onto the canvas
Parameters:
Name Type Attributes Default Description
scene THREE.Scene THREE.Scene
params object <optional>
{} The following parameters are available
Properties
Name Type Attributes Default Description
center object <optional>
{x: 0.0, y: 0.0, z: 0.0} center of the hypersphere
Properties
Name Type Attributes Default Description
x float <optional>
0.0 X axis of the center
y float <optional>
0.0 Y axis of the center
z float <optional>
0.0 Z axis of the center
Source:

pushRandomLongitude(verticeAngles)

Push random longitude into vertice angles
Parameters:
Name Type Description
verticeAngles array vertice angles
Source:

vertice2angles(vertice)

Converts a vertice position to vertice angles.
Parameters:
Name Type Description
vertice array array of the vertice axes
Source:
Returns:
Vertice angles.