Reputation: 17
I am trying to convert the function below to Python, but I am not sure what is going on.
function [ray]=create_ray(point1,direction)
ray.direction.x=direction.x;
ray.coefficients.x=(point1.x);
ray.direction.y=direction.y;
ray.coefficients.y=(point1.y);
ray.direction.z=direction.z;
ray.coefficients.z=(point1.z);
I know that it returns an array, ray, but what exactly is it doing with direction and coefficients? Could someone please explain to me what is going on. Any help would be greatly appreciated.
Upvotes: 0
Views: 62
Reputation: 6186
ray
is the return value. The python version will be
def create_ray(point1, direction):
...
return ray
where ray
is function [
ray]=create_ray(point1,direction)
in the Matlab code.
BTW, the ray
would be defined by class
in Python. So the final code can be
class Direction(object):
x, y, z = None, None, None
class Coefficients(object):
x, y, z = None, None, None
class Ray(object):
direction = Direction()
coefficients = Coefficients()
def create_ray(point1, direction):
ray = Ray()
ray.direction.x = direction.x;
ray.coefficients.x = point1.x;
ray.direction.y = direction.y;
ray.coefficients.y = point1.y;
ray.direction.z = direction.z;
ray.coefficients.z = point1.z;
return ray
Upvotes: 3