# Sphere

vtk-examples/Python/GeometricObjects/Sphere

### Description¶

vtkSphereSource object creates a sphere (represented by polygons) of specified radius centered at the origin.

The resolution (polygonal discretization) in both the latitude (phi) and longitude (theta) directions can be specified.

It also is possible to create partial spheres by specifying maximum phi and theta angles. By default, the surface tessellation of the sphere uses triangles; however you can set LatLongTessellation to produce a tessellation using quadrilaterals.

Other languages

See (Cxx), (CSharp)

Question

### Code¶

Sphere.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import vtk

def main():
colors = vtk.vtkNamedColors()

# Create a sphere
sphereSource = vtk.vtkSphereSource()
sphereSource.SetCenter(0.0, 0.0, 0.0)
# Make the surface smooth.
sphereSource.SetPhiResolution(100)
sphereSource.SetThetaResolution(100)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(sphereSource.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.GetProperty().SetColor(colors.GetColor3d("Cornsilk"))

renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.SetWindowName("Sphere")