Commit 53cc853f authored by Julien Jerphanion's avatar Julien Jerphanion
Browse files

Add examples folder

parent 6d8a9417
Pipeline #143237 failed with stage
in 11 minutes and 9 seconds
import tensorflow as tf
import numpy as np
from sft.spline.surface_models import SplineSphere
if __name__ == '__main__':
Ms = 4
Mt = 4
use_tf = True
center = (-12.3, 37, 1337)
radius = 2000
control_points = np.zeros((Ms * Mt, 3))
PIMs = np.pi / (Ms - 1)
PIMt = np.pi / Mt
scaleMs = 2.0 * (1.0 - np.cos(PIMs)) / (np.cos(PIMs / 2) - np.cos(3.0 * PIMs / 2))
scaleMt = 2.0 * (1.0 - np.cos(2.0 * PIMt)) / (np.cos(PIMt) - np.cos(3.0 * PIMt))
for l in range(0, Ms):
for k in range(0, Mt):
ip = k + Mt * l
theta = l * PIMs
phi = 2.0 * k * PIMt
point = np.array([
scaleMs * scaleMt * np.cos(phi) * np.sin(theta),
scaleMs * scaleMt * np.sin(phi) * np.sin(theta),
scaleMs * np.cos(theta)])
control_points[ip] = center + radius * point
control_points_tf = tf.convert_to_tensor(control_points)
surface = SplineSphere(M=(Ms, Mt))
surface_tf = SplineSphere(M=(Ms, Mt))
surface.control_points = control_points
surface.north_pole = center + np.array([0, 0, radius])
surface.south_pole = center + np.array([0, 0, -radius])
surface_tf.control_points = control_points_tf
surface_tf.north_pole = center + np.array([0, 0, radius])
surface_tf.south_pole = center + np.array([0, 0, -radius])
tans = np.array([
surface.north_pole + np.array([radius * np.pi, 0, 0]),
surface.north_pole + np.array([0, radius * np.pi, 0]),
surface.south_pole + np.array([radius * np.pi, 0, 0]),
surface.south_pole + np.array([0, radius * np.pi, 0]),
])
surface.tans = tans
surface_tf.tans = tans
# Check for same sampled points
sample_points = surface.sample(sampling_rates=(51, 50))
sample_points_tf = surface_tf.sample(sampling_rates=(50, 51))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment