-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSphere.cs
More file actions
30 lines (22 loc) · 720 Bytes
/
Sphere.cs
File metadata and controls
30 lines (22 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
public class Sphere: AbstractSurface{
public class diffeo: AbstractDiffeomorphism{
float r;
public diffeo(float rad){
r = rad;
_uMin = 0;
_uMax = 3.14f;
_vMin = 0;
_vMax = 6.28f;
}
public override Vector3 call(Vector2 pt){
float u = pt.x;
float v = pt.y;
return new Vector3(r * Mathf.Sin(u) * Mathf.Cos(v), r * Mathf.Sin(u) * Mathf.Sin(v), r * Mathf.Cos(u));
}
}
public Sphere(float radius): base(){
diffeo d = new diffeo(radius);
base.setPatches(new AbstractDiffeomorphism[] {d});
}
}