Skip to main content

vScriptValGenerateSphere

Generate points along latitude circles and longitude lines of a sphere, with trim controls for the poles.

BeginnerMograph / ScriptValScriptValArrayJSON
vScriptValGenerateSphere node

vScriptValGenerateSphere has no input and outputs an array of XYZ points on circles of latitude and lines of longitude of a sphere around the origin, with the polar axis along Z. Number Lat Lines and Number Lon Lines set how many lines are drawn.

Parameters​

ParameterTypeDefaultDescription
RadiusFloat0.3Radius of the sphere. Default 0.3.
Number Lat LinesInteger1Number of latitude circles. Minimum 0, default 1.
Number Lon LinesInteger1Number of longitude lines. Minimum 0, default 1.
Trim TopFloat0Fraction of the 90 degrees from the equator to the north pole that is cut away at the top. Minimum -1, default 0.
Trim BottomFloat0Fraction of the 90 degrees from the equator to the south pole that is cut away at the bottom. Minimum -1, default 0.
+1 more parameters
ParameterTypeDefaultDescription
Include Lon LinesInteger0.0This control has no effect. Longitude lines are always written. Default off.
Read the full description

Number Lat Lines circles are spaced evenly in latitude between the poles, not including the poles. Each circle has 101 points, from longitude 0 to 360 degrees, so the last point repeats the first. A circle at latitude a has the radius Radius * cos(a) and sits at Z = Radius * sin(a).

Number Lon Lines lines are spaced evenly in longitude, and each runs from the south pole to the north pole with 100 points. The longitude lines are always written. The Include Lon Lines checkbox does not change the output, because the code tests the value as a boolean and a Lua number, including 0, counts as true.

Trim Top and Trim Bottom remove points near the poles. Each value is a fraction of the 90 degrees between the equator and a pole. Points above latitude 90 degrees minus Trim Top * 90 degrees, and below -90 degrees plus Trim Bottom * 90 degrees, are left out of both the latitude circles and the longitude lines. Negative values extend the limits past the poles and remove nothing.

With the defaults (Radius 0.3, 1 latitude line, 1 longitude line, no trim) the node outputs 201 points, the equator circle with 101 points and one meridian with 100 points. Radius is not limited, so a negative Radius mirrors the sphere.

Example Connections​

vScriptValGenerateSphere.Output -> vScriptValCameraProjection.ArrayA
vScriptValCameraProjection.Output -> vScriptValShapeRender.ArrayPoint
Background.Output -> vScriptValShapeRender.Input