/ miniRT / practice / miniRT_practice / vector_product.c
vector_product.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   vector_product.c                                   :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: salee2 <salee2@student.42seoul.kr>         +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2023/06/02 16:34:40 by salee2            #+#    #+#             */
 9  /*   Updated: 2023/06/02 16:34:42 by salee2           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "include/minirt.h"
14  
15  t_vec3	scl_mul(double t, t_vec3 vector)
16  {
17  	return (vec3_(t * vector.ai, t * vector.bj, t * vector.ck));
18  }
19  
20  double	dot(t_vec3 u, t_vec3 v)
21  {
22  	return (u.ai * v.ai + u.bj * v.bj + u.ck * v.ck);
23  }
24  
25  t_vec3	cross(t_vec3 u, t_vec3 v)
26  {
27  	return (vec3_(u.bj * v.ck - u.ck * v.bj, u.ck * v.ai - u.ai * v.ck, \
28  	u.ai * v.bj - u.bj * v.ai));
29  }
30  
31  t_vec3	elem_prod(t_vec3 u, t_vec3 v)
32  {
33  	return (vec3_(u.ai * v.ai, u.bj * v.bj, u.ck * v.ck));
34  }