#include "point.cuh"

// Default constructor
__host__ __device__
Point::Point()
{
    this->x = 0;
    this->y = 0;
    this->z = 0;
}

// Normal constructor
__host__ __device__
Point::Point(float x, float y, float z)
{
    this->x = x;
    this->y = y;
    this->z = z;
}

// Returns the norm of a point treated like a vector
__host__ __device__
Point Point::norm()
{
    Point result;
    result = *this;
    
    float mag = sqrt(this->x * this->x +
                     this->y * this->y +
                     this->z * this->z);
    result /= mag;
    return result;
}

// Dot product of two points treated like vectors
__host__ __device__
float Point::dot(Point p)
{
    return this->x * p.x + this->y * p.y + this->z * p.z;
}

// Cross product of two points treated like vectors
__host__ __device__
Point Point::cross(Point p)
{
    Point result =  Point(this->y * p.z - this->z * p.y,
                               this->z * p.x - this->x * p.z,
                               this->x * p.y - this->y * p.x);

    return result;
}

// Calculates the Euclidean distance between 2 points
__host__ __device__
float Point::dist(Point p)
{
    float dx = p.x - this->x;
    float dy = p.y - this->y;
    float dz = p.z - this->z;

    return sqrt(dx * dx + dy * dy + dz * dz);
}

__host__ __device__
Point Point::cwiseMin(Point p)
{
    float minx, miny, minz;
    minx = (this->x < p.X()) ? this->x : p.X();
    miny = (this->y < p.Y()) ? this->y : p.Y();
    minz = (this->z < p.Z()) ? this->z : p.Z();

    return Point (minx, miny, minz);
}

// OPERATOR OVERLOADS
__host__ __device__
Point Point::operator+(Point p)
{
    Point result = Point(this->x + p.x,
                               this->y + p.y,
                               this->z + p.z);
    return result;
}

__host__ __device__
Point Point::operator-(Point p)
{
    Point result = Point(this->x - p.x,
                               this->y - p.y,
                               this->z - p.z);
    return result;
}

__host__ __device__
Point Point::operator*(Point p)
{
    Point result = Point(this->x * p.x,
                               this->y * p.y,
                               this->z * p.z);
    return result;
}

__host__ __device__
Point Point::operator/(Point p)
{
    Point result = Point(this->x / p.x,
                               this->y / p.y,
                               this->z / p.z);
    return result;
}

__host__ __device__
Point Point::operator+=(Point p)
{
    this->x += p.x;
    this->y += p.y;
    this->z += p.z;

    return *this;
}

__host__ __device__
Point Point::operator-=(Point p)
{
    this->x -= p.x;
    this->y -= p.y;
    this->z -= p.z;

    return *this;
}

__host__ __device__
Point Point::operator*=(Point p)
{
    this->x *= p.x;
    this->y *= p.y;
    this->z *= p.z;

    return *this;
}

__host__ __device__
Point Point::operator/=(Point p)
{
    this->x /= p.x;
    this->y /= p.y;
    this->z /= p.z;

    return *this;
}

__host__ __device__
Point Point::operator+(float f)
{
    Point result = Point(this->x + f,
                               this->y + f,
                               this->z + f);
    return result;
}

__host__ __device__
Point Point::operator-(float f)
{
    Point result = Point(this->x - f,
                               this->y - f,
                               this->z - f);
    return result;
}

__host__ __device__
Point Point::operator*(float f)
{
    Point result = Point(this->x * f,
                               this->y * f,
                               this->z * f);
    return result;
}

__host__ __device__
Point Point::operator/(float f)
{
    Point result = Point(this->x / f,
                               this->y / f,
                               this->z / f);
    return result;
}

__host__ __device__
Point Point::operator+=(float f)
{
    this->x += f;
    this->y += f;
    this->z += f;

    return *this;
}

__host__ __device__
Point Point::operator-=(float f)
{
    this->x -= f;
    this->y -= f;
    this->z -= f;
    return *this;
}

__host__ __device__
Point Point::operator*=(float f)
{
    this->x *= f;
    this->y *= f;
    this->z *= f;
    return *this;
}

__host__ __device__
Point Point::operator/=(float f)
{
    this->x /= f;
    this->y /= f;
    this->z /= f;
    return *this;
}

__host__ __device__
Point Point::operator=(Point p)
{
    this->x = p.x;
    this->y = p.y;
    this->z = p.z;
    return *this;
}

__host__ __device__
bool Point::operator==(Point p)
{
    if (this->x == p.x && this->y == p.y && this->z == p.z)
    {
        return true;
    }

    return false;
}


// Stream output operator
__host__
std::ostream& operator<<(std::ostream &out, Point p)
{
    out << p.x << "\t" << p.y << "\t" << p.z << "\n";
    return out;
}

/******************************************************************************/
/*                           Methods for Ray Class                            */
/******************************************************************************/
__host__ __device__
Ray::Ray()
{
    // Default direction
    this->x = 1;
    this->y = 1;
    this->z = 1;

    // Located at the origin
    this->posx = 0;
    this->posy = 0;
    this->posz = 0;
    
    // Default color black
    this->setColor(0, 0, 0);
    this->t = FLT_MAX;
}

__host__ __device__
Ray::Ray(float X, float Y, float Z, float dX, float dY, float dZ)
{
    this->x = dX;
    this->y = dY;
    this->z = dZ;
    this->posx = X;
    this->posy = Y;
    this->posz = Z;

    // Default color black
    this->setColor(0, 0, 0);
    this->t = FLT_MAX;
}

__host__ __device__
Ray::Ray(Point dp, Point p)
{
    this->x = dp.X();
    this->y = dp.Y();
    this->z = dp.Z();
    this->posx = p.X();
    this->posy = p.Y();
    this->posz = p.Z();
    
    // Default color black./
    this->setColor(0, 0, 0);
    this->t = FLT_MAX;
}

__host__ __device__
void Ray::setColor(int r, int g, int b)
{
    this->R = r;
    this->G = g;
    this->B = b;
}

__host__ __device__
void Ray::setDir(Point p)
{
    this->x = p.X();
    this->y = p.Y();
    this->z = p.Z();
}

__host__ __device__
void Ray::setStart(Point p)
{
    this->posx = p.X();
    this->posy = p.Y();
    this->posz = p.Z();
}

__host__ __device__
Point Ray::propagate(float time)
{
    return Point(this->x * time + this->posx,
                     this->y * time + this->posy,
                     this->z * time + this->posz);
}


///////////////////////////////////////////////////////////////////////////////
// Point Light operations
///////////////////////////////////////////////////////////////////////////////
__host__ __device__
pointLight::pointLight()
{
    this->setPos(5, 5, 5);
    this->setColor(0, 140, 125);
    this->setAtt_k(0.0005);
}

__host__ __device__
pointLight::pointLight(float X, float Y, float Z,
                       int r, int g, int b, float att_k)
{
    this->setPos(X, Y, Z);
    this->setColor(r, g, b);
    this->setAtt_k(att_k);
}

__host__ __device__
pointLight::pointLight(Point p, int r, int g, int b, float att_k)
{
    this->setPos(p);
    this->setColor(r, g, b);
    this->setAtt_k(att_k);
}

__host__ __device__
void pointLight::setColor(int r, int g, int b)
{
    this->R = r;
    this->G = g;
    this->B = b;
}

__host__ __device__
Point pointLight::getColor()
{
    return Point(this->R, this->G, this->B);
}

__host__ __device__
void pointLight::setAtt_k(float att_k)
{
    this->attenuation_k = att_k;
}

__host__ __device__
float pointLight::getAtt_k()
{
    return this->attenuation_k;
}

__host__ __device__
void pointLight::setPos(Point p)
{
    this->setPos(p.X(), p.Y(), p.Z());
}

__host__ __device__
void pointLight::setPos(float X, float Y, float Z)
{
    this->x = X;
    this->y = Y;
    this->z = Z;
}

__host__ __device__
Point pointLight::getPos()
{
    return Point(this->x, this->y, this->z);
}

	.file	"tmpxft_00262043_00000000-6_point.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3711:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3711:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.globl	_ZN5PointC2Ev
	.type	_ZN5PointC2Ev, @function
_ZN5PointC2Ev:
.LFB3651:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	movl	$0x00000000, 8(%rdi)
	movq	%rax, (%rdi)
	ret
	.cfi_endproc
.LFE3651:
	.size	_ZN5PointC2Ev, .-_ZN5PointC2Ev
	.globl	_ZN5PointC1Ev
	.set	_ZN5PointC1Ev,_ZN5PointC2Ev
	.align 2
	.globl	_ZN5PointC2Efff
	.type	_ZN5PointC2Efff, @function
_ZN5PointC2Efff:
.LFB3654:
	.cfi_startproc
	endbr64
	movss	%xmm0, (%rdi)
	movss	%xmm1, 4(%rdi)
	movss	%xmm2, 8(%rdi)
	ret
	.cfi_endproc
.LFE3654:
	.size	_ZN5PointC2Efff, .-_ZN5PointC2Efff
	.globl	_ZN5PointC1Efff
	.set	_ZN5PointC1Efff,_ZN5PointC2Efff
	.align 2
	.globl	_ZN5Point3dotES_
	.type	_ZN5Point3dotES_, @function
_ZN5Point3dotES_:
.LFB3657:
	.cfi_startproc
	endbr64
	movq	%xmm0, -16(%rsp)
	movss	4(%rdi), %xmm2
	movss	(%rdi), %xmm0
	mulss	-12(%rsp), %xmm2
	mulss	-16(%rsp), %xmm0
	mulss	8(%rdi), %xmm1
	addss	%xmm2, %xmm0
	addss	%xmm1, %xmm0
	ret
	.cfi_endproc
.LFE3657:
	.size	_ZN5Point3dotES_, .-_ZN5Point3dotES_
	.align 2
	.globl	_ZN5Point5crossES_
	.type	_ZN5Point5crossES_, @function
_ZN5Point5crossES_:
.LFB3658:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	4(%rdi), %xmm2
	movss	8(%rdi), %xmm0
	movss	-40(%rsp), %xmm5
	movss	-36(%rsp), %xmm6
	movss	(%rdi), %xmm3
	movaps	%xmm2, %xmm4
	movaps	%xmm0, %xmm7
	mulss	%xmm1, %xmm4
	mulss	%xmm6, %xmm7
	mulss	%xmm3, %xmm1
	mulss	%xmm5, %xmm0
	mulss	%xmm6, %xmm3
	mulss	%xmm5, %xmm2
	subss	%xmm7, %xmm4
	subss	%xmm1, %xmm0
	movaps	%xmm3, %xmm1
	movss	%xmm4, -20(%rsp)
	subss	%xmm2, %xmm1
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3658:
	.size	_ZN5Point5crossES_, .-_ZN5Point5crossES_
	.align 2
	.globl	_ZN5Point4distES_
	.type	_ZN5Point4distES_, @function
_ZN5Point4distES_:
.LFB3659:
	.cfi_startproc
	endbr64
	movq	%xmm0, -24(%rsp)
	movss	-24(%rsp), %xmm0
	subss	(%rdi), %xmm0
	movss	-20(%rsp), %xmm2
	subss	4(%rdi), %xmm2
	subss	8(%rdi), %xmm1
	mulss	%xmm0, %xmm0
	mulss	%xmm2, %xmm2
	mulss	%xmm1, %xmm1
	addss	%xmm2, %xmm0
	addss	%xmm1, %xmm0
	jmp	sqrtf@PLT
	.cfi_endproc
.LFE3659:
	.size	_ZN5Point4distES_, .-_ZN5Point4distES_
	.align 2
	.globl	_ZN5Point8cwiseMinES_
	.type	_ZN5Point8cwiseMinES_, @function
_ZN5Point8cwiseMinES_:
.LFB3660:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	8(%rdi), %xmm5
	movss	(%rdi), %xmm0
	movaps	%xmm5, %xmm2
	movaps	%xmm0, %xmm4
	movss	4(%rdi), %xmm0
	minss	-40(%rsp), %xmm4
	cmpnltss	%xmm1, %xmm2
	movaps	%xmm0, %xmm3
	minss	-36(%rsp), %xmm3
	movss	%xmm4, -20(%rsp)
	andps	%xmm2, %xmm1
	andnps	%xmm5, %xmm2
	movss	%xmm3, -16(%rsp)
	orps	%xmm2, %xmm1
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3660:
	.size	_ZN5Point8cwiseMinES_, .-_ZN5Point8cwiseMinES_
	.align 2
	.globl	_ZN5PointplES_
	.type	_ZN5PointplES_, @function
_ZN5PointplES_:
.LFB3661:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm2
	movss	4(%rdi), %xmm0
	addss	-40(%rsp), %xmm2
	addss	-36(%rsp), %xmm0
	addss	8(%rdi), %xmm1
	movss	%xmm2, -20(%rsp)
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3661:
	.size	_ZN5PointplES_, .-_ZN5PointplES_
	.align 2
	.globl	_ZN5PointmiES_
	.type	_ZN5PointmiES_, @function
_ZN5PointmiES_:
.LFB3662:
	.cfi_startproc
	endbr64
	movss	8(%rdi), %xmm3
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm2
	movss	4(%rdi), %xmm0
	subss	-40(%rsp), %xmm2
	subss	-36(%rsp), %xmm0
	subss	%xmm1, %xmm3
	movss	%xmm2, -20(%rsp)
	movss	%xmm0, -16(%rsp)
	movaps	%xmm3, %xmm1
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3662:
	.size	_ZN5PointmiES_, .-_ZN5PointmiES_
	.align 2
	.globl	_ZN5PointmlES_
	.type	_ZN5PointmlES_, @function
_ZN5PointmlES_:
.LFB3663:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm2
	movss	4(%rdi), %xmm0
	mulss	-40(%rsp), %xmm2
	mulss	-36(%rsp), %xmm0
	mulss	8(%rdi), %xmm1
	movss	%xmm2, -20(%rsp)
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3663:
	.size	_ZN5PointmlES_, .-_ZN5PointmlES_
	.align 2
	.globl	_ZN5PointdvES_
	.type	_ZN5PointdvES_, @function
_ZN5PointdvES_:
.LFB3664:
	.cfi_startproc
	endbr64
	movss	8(%rdi), %xmm3
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm2
	divss	-40(%rsp), %xmm2
	movss	4(%rdi), %xmm0
	movss	%xmm2, -20(%rsp)
	divss	-36(%rsp), %xmm0
	divss	%xmm1, %xmm3
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	movaps	%xmm3, %xmm1
	ret
	.cfi_endproc
.LFE3664:
	.size	_ZN5PointdvES_, .-_ZN5PointdvES_
	.align 2
	.globl	_ZN5PointpLES_
	.type	_ZN5PointpLES_, @function
_ZN5PointpLES_:
.LFB3665:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm0
	addss	8(%rdi), %xmm1
	addss	-40(%rsp), %xmm0
	movss	%xmm1, 8(%rdi)
	movl	8(%rdi), %eax
	movss	%xmm0, (%rdi)
	movss	4(%rdi), %xmm0
	addss	-36(%rsp), %xmm0
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	movss	%xmm0, 4(%rdi)
	movq	(%rdi), %xmm0
	ret
	.cfi_endproc
.LFE3665:
	.size	_ZN5PointpLES_, .-_ZN5PointpLES_
	.align 2
	.globl	_ZN5PointmIES_
	.type	_ZN5PointmIES_, @function
_ZN5PointmIES_:
.LFB3666:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm0
	subss	-40(%rsp), %xmm0
	movss	%xmm0, (%rdi)
	movss	4(%rdi), %xmm0
	subss	-36(%rsp), %xmm0
	movss	%xmm0, 4(%rdi)
	movss	8(%rdi), %xmm0
	subss	%xmm1, %xmm0
	movss	%xmm0, 8(%rdi)
	movl	8(%rdi), %eax
	movq	(%rdi), %xmm0
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3666:
	.size	_ZN5PointmIES_, .-_ZN5PointmIES_
	.align 2
	.globl	_ZN5PointmLES_
	.type	_ZN5PointmLES_, @function
_ZN5PointmLES_:
.LFB3667:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm0
	mulss	8(%rdi), %xmm1
	mulss	-40(%rsp), %xmm0
	movss	%xmm1, 8(%rdi)
	movl	8(%rdi), %eax
	movss	%xmm0, (%rdi)
	movss	4(%rdi), %xmm0
	mulss	-36(%rsp), %xmm0
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	movss	%xmm0, 4(%rdi)
	movq	(%rdi), %xmm0
	ret
	.cfi_endproc
.LFE3667:
	.size	_ZN5PointmLES_, .-_ZN5PointmLES_
	.align 2
	.globl	_ZN5PointdVES_
	.type	_ZN5PointdVES_, @function
_ZN5PointdVES_:
.LFB3668:
	.cfi_startproc
	endbr64
	movq	%xmm0, -40(%rsp)
	movss	(%rdi), %xmm0
	divss	-40(%rsp), %xmm0
	movss	%xmm0, (%rdi)
	movss	4(%rdi), %xmm0
	divss	-36(%rsp), %xmm0
	movss	%xmm0, 4(%rdi)
	movss	8(%rdi), %xmm0
	divss	%xmm1, %xmm0
	movss	%xmm0, 8(%rdi)
	movl	8(%rdi), %eax
	movq	(%rdi), %xmm0
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3668:
	.size	_ZN5PointdVES_, .-_ZN5PointdVES_
	.align 2
	.globl	_ZN5PointplEf
	.type	_ZN5PointplEf, @function
_ZN5PointplEf:
.LFB3669:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm1
	movss	(%rdi), %xmm2
	movss	4(%rdi), %xmm0
	addss	%xmm1, %xmm2
	addss	%xmm1, %xmm0
	addss	8(%rdi), %xmm1
	movss	%xmm2, -20(%rsp)
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3669:
	.size	_ZN5PointplEf, .-_ZN5PointplEf
	.align 2
	.globl	_ZN5PointmiEf
	.type	_ZN5PointmiEf, @function
_ZN5PointmiEf:
.LFB3670:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm2
	movss	(%rdi), %xmm3
	movss	4(%rdi), %xmm0
	movss	8(%rdi), %xmm1
	subss	%xmm2, %xmm0
	subss	%xmm2, %xmm3
	subss	%xmm2, %xmm1
	movss	%xmm3, -20(%rsp)
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3670:
	.size	_ZN5PointmiEf, .-_ZN5PointmiEf
	.align 2
	.globl	_ZN5PointmlEf
	.type	_ZN5PointmlEf, @function
_ZN5PointmlEf:
.LFB3671:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm1
	movss	(%rdi), %xmm2
	movss	4(%rdi), %xmm0
	mulss	%xmm1, %xmm2
	mulss	%xmm1, %xmm0
	mulss	8(%rdi), %xmm1
	movss	%xmm2, -20(%rsp)
	movss	%xmm0, -16(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3671:
	.size	_ZN5PointmlEf, .-_ZN5PointmlEf
	.align 2
	.globl	_ZN5PointdvEf
	.type	_ZN5PointdvEf, @function
_ZN5PointdvEf:
.LFB3672:
	.cfi_startproc
	endbr64
	movaps	%xmm0, %xmm2
	movss	(%rdi), %xmm3
	movss	4(%rdi), %xmm0
	movss	8(%rdi), %xmm1
	divss	%xmm2, %xmm0
	divss	%xmm2, %xmm3
	movss	%xmm0, -16(%rsp)
	divss	%xmm2, %xmm1
	movss	%xmm3, -20(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3672:
	.size	_ZN5PointdvEf, .-_ZN5PointdvEf
	.align 2
	.globl	_ZN5PointpLEf
	.type	_ZN5PointpLEf, @function
_ZN5PointpLEf:
.LFB3673:
	.cfi_startproc
	endbr64
	movss	(%rdi), %xmm1
	addss	%xmm0, %xmm1
	movss	%xmm1, (%rdi)
	movss	4(%rdi), %xmm1
	addss	%xmm0, %xmm1
	addss	8(%rdi), %xmm0
	movss	%xmm0, 8(%rdi)
	movl	8(%rdi), %eax
	movss	%xmm1, 4(%rdi)
	movq	(%rdi), %xmm0
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3673:
	.size	_ZN5PointpLEf, .-_ZN5PointpLEf
	.align 2
	.globl	_ZN5PointmIEf
	.type	_ZN5PointmIEf, @function
_ZN5PointmIEf:
.LFB3674:
	.cfi_startproc
	endbr64
	movss	(%rdi), %xmm1
	subss	%xmm0, %xmm1
	movss	%xmm1, (%rdi)
	movss	4(%rdi), %xmm1
	subss	%xmm0, %xmm1
	movss	%xmm1, 4(%rdi)
	movss	8(%rdi), %xmm1
	subss	%xmm0, %xmm1
	movq	(%rdi), %xmm0
	movss	%xmm1, 8(%rdi)
	movl	8(%rdi), %eax
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3674:
	.size	_ZN5PointmIEf, .-_ZN5PointmIEf
	.align 2
	.globl	_ZN5PointmLEf
	.type	_ZN5PointmLEf, @function
_ZN5PointmLEf:
.LFB3675:
	.cfi_startproc
	endbr64
	movss	(%rdi), %xmm1
	mulss	%xmm0, %xmm1
	movss	%xmm1, (%rdi)
	movss	4(%rdi), %xmm1
	mulss	%xmm0, %xmm1
	mulss	8(%rdi), %xmm0
	movss	%xmm1, 4(%rdi)
	movss	%xmm0, 8(%rdi)
	movl	8(%rdi), %eax
	movq	(%rdi), %xmm0
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3675:
	.size	_ZN5PointmLEf, .-_ZN5PointmLEf
	.align 2
	.globl	_ZN5PointdVEf
	.type	_ZN5PointdVEf, @function
_ZN5PointdVEf:
.LFB3676:
	.cfi_startproc
	endbr64
	movss	(%rdi), %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, (%rdi)
	movss	4(%rdi), %xmm1
	divss	%xmm0, %xmm1
	movss	%xmm1, 4(%rdi)
	movss	8(%rdi), %xmm1
	divss	%xmm0, %xmm1
	movq	(%rdi), %xmm0
	movss	%xmm1, 8(%rdi)
	movl	8(%rdi), %eax
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3676:
	.size	_ZN5PointdVEf, .-_ZN5PointdVEf
	.align 2
	.globl	_ZN5Point4normEv
	.type	_ZN5Point4normEv, @function
_ZN5Point4normEv:
.LFB3656:
	.cfi_startproc
	endbr64
	subq	$56, %rsp
	.cfi_def_cfa_offset 64
	movss	(%rdi), %xmm0
	movss	4(%rdi), %xmm2
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	movss	8(%rdi), %xmm1
	movss	%xmm0, 16(%rsp)
	mulss	%xmm0, %xmm0
	movss	%xmm2, 20(%rsp)
	mulss	%xmm2, %xmm2
	movss	%xmm1, 24(%rsp)
	mulss	%xmm1, %xmm1
	addss	%xmm2, %xmm0
	addss	%xmm1, %xmm0
	call	sqrtf@PLT
	leaq	16(%rsp), %rdi
	call	_ZN5PointdVEf
	movl	24(%rsp), %eax
	movq	16(%rsp), %xmm0
	movl	%eax, 36(%rsp)
	movss	36(%rsp), %xmm1
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	je	.L34
	call	__stack_chk_fail@PLT
.L34:
	addq	$56, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3656:
	.size	_ZN5Point4normEv, .-_ZN5Point4normEv
	.align 2
	.globl	_ZN5PointaSES_
	.type	_ZN5PointaSES_, @function
_ZN5PointaSES_:
.LFB3677:
	.cfi_startproc
	endbr64
	movss	%xmm1, 8(%rdi)
	movl	8(%rdi), %eax
	movq	%xmm0, (%rdi)
	movl	%eax, -12(%rsp)
	movss	-12(%rsp), %xmm1
	ret
	.cfi_endproc
.LFE3677:
	.size	_ZN5PointaSES_, .-_ZN5PointaSES_
	.align 2
	.globl	_ZN5PointeqES_
	.type	_ZN5PointeqES_, @function
_ZN5PointeqES_:
.LFB3678:
	.cfi_startproc
	endbr64
	movq	%xmm0, -16(%rsp)
	movss	(%rdi), %xmm0
	ucomiss	-16(%rsp), %xmm0
	movss	%xmm1, -8(%rsp)
	jp	.L43
	jne	.L43
	movss	4(%rdi), %xmm0
	ucomiss	-12(%rsp), %xmm0
	jp	.L43
	jne	.L43
	movss	8(%rdi), %xmm0
	movb	$0, %dl
	ucomiss	%xmm1, %xmm0
	setnp	%al
	cmovne	%edx, %eax
	ret
.L43:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE3678:
	.size	_ZN5PointeqES_, .-_ZN5PointeqES_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"\t"
.LC2:
	.string	"\n"
	.text
	.globl	_ZlsRSo5Point
	.type	_ZlsRSo5Point, @function
_ZlsRSo5Point:
.LFB3679:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movss	%xmm1, 8(%rsp)
	movq	%xmm0, (%rsp)
	cvtss2sd	(%rsp), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	4(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	8(%rsp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	movq	%rbx, %rax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3679:
	.size	_ZlsRSo5Point, .-_ZlsRSo5Point
	.align 2
	.globl	_ZN3RayC2Ev
	.type	_ZN3RayC2Ev, @function
_ZN3RayC2Ev:
.LFB3681:
	.cfi_startproc
	endbr64
	movabsq	$4575657222473777152, %rax
	movq	$1065353216, 8(%rdi)
	movq	%rax, (%rdi)
	xorl	%eax, %eax
	movq	%rax, 16(%rdi)
	movq	%rax, 24(%rdi)
	movl	$2139095039, %eax
	salq	$32, %rax
	movq	%rax, 32(%rdi)
	ret
	.cfi_endproc
.LFE3681:
	.size	_ZN3RayC2Ev, .-_ZN3RayC2Ev
	.globl	_ZN3RayC1Ev
	.set	_ZN3RayC1Ev,_ZN3RayC2Ev
	.align 2
	.globl	_ZN3RayC2Effffff
	.type	_ZN3RayC2Effffff, @function
_ZN3RayC2Effffff:
.LFB3684:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	movss	%xmm3, (%rdi)
	movq	%rax, 24(%rdi)
	movl	$2139095039, %eax
	salq	$32, %rax
	movss	%xmm4, 4(%rdi)
	movq	%rax, 32(%rdi)
	movss	%xmm5, 8(%rdi)
	movss	%xmm0, 12(%rdi)
	movss	%xmm1, 16(%rdi)
	movss	%xmm2, 20(%rdi)
	ret
	.cfi_endproc
.LFE3684:
	.size	_ZN3RayC2Effffff, .-_ZN3RayC2Effffff
	.globl	_ZN3RayC1Effffff
	.set	_ZN3RayC1Effffff,_ZN3RayC2Effffff
	.align 2
	.globl	_ZN3RayC2E5PointS0_
	.type	_ZN3RayC2E5PointS0_, @function
_ZN3RayC2E5PointS0_:
.LFB3687:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	movq	%xmm0, (%rdi)
	movq	%rax, 24(%rdi)
	movl	$2139095039, %eax
	salq	$32, %rax
	movss	%xmm1, 8(%rdi)
	movq	%rax, 32(%rdi)
	movq	%xmm2, 12(%rdi)
	movss	%xmm3, 20(%rdi)
	ret
	.cfi_endproc
.LFE3687:
	.size	_ZN3RayC2E5PointS0_, .-_ZN3RayC2E5PointS0_
	.globl	_ZN3RayC1E5PointS0_
	.set	_ZN3RayC1E5PointS0_,_ZN3RayC2E5PointS0_
	.align 2
	.globl	_ZN3Ray8setColorEiii
	.type	_ZN3Ray8setColorEiii, @function
_ZN3Ray8setColorEiii:
.LFB3689:
	.cfi_startproc
	endbr64
	movl	%esi, 24(%rdi)
	movl	%edx, 28(%rdi)
	movl	%ecx, 32(%rdi)
	ret
	.cfi_endproc
.LFE3689:
	.size	_ZN3Ray8setColorEiii, .-_ZN3Ray8setColorEiii
	.align 2
	.globl	_ZN3Ray6setDirE5Point
	.type	_ZN3Ray6setDirE5Point, @function
_ZN3Ray6setDirE5Point:
.LFB3690:
	.cfi_startproc
	endbr64
	movq	%xmm0, (%rdi)
	movss	%xmm1, 8(%rdi)
	ret
	.cfi_endproc
.LFE3690:
	.size	_ZN3Ray6setDirE5Point, .-_ZN3Ray6setDirE5Point
	.align 2
	.globl	_ZN3Ray8setStartE5Point
	.type	_ZN3Ray8setStartE5Point, @function
_ZN3Ray8setStartE5Point:
.LFB3691:
	.cfi_startproc
	endbr64
	movq	%xmm0, 12(%rdi)
	movss	%xmm1, 20(%rdi)
	ret
	.cfi_endproc
.LFE3691:
	.size	_ZN3Ray8setStartE5Point, .-_ZN3Ray8setStartE5Point
	.align 2
	.globl	_ZN3Ray9propagateEf
	.type	_ZN3Ray9propagateEf, @function
_ZN3Ray9propagateEf:
.LFB3692:
	.cfi_startproc
	endbr64
	movss	8(%rdi), %xmm1
	movss	4(%rdi), %xmm2
	mulss	%xmm0, %xmm1
	mulss	%xmm0, %xmm2
	addss	20(%rdi), %xmm1
	mulss	(%rdi), %xmm0
	addss	16(%rdi), %xmm2
	addss	12(%rdi), %xmm0
	movss	%xmm2, -16(%rsp)
	movss	%xmm0, -20(%rsp)
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3692:
	.size	_ZN3Ray9propagateEf, .-_ZN3Ray9propagateEf
	.align 2
	.globl	_ZN10pointLightC2Ev
	.type	_ZN10pointLightC2Ev, @function
_ZN10pointLightC2Ev:
.LFB3694:
	.cfi_startproc
	endbr64
	movabsq	$4656722015785320448, %rax
	movq	$1084227584, 8(%rdi)
	movq	%rax, (%rdi)
	movabsq	$536870912140, %rax
	movq	%rax, 16(%rdi)
	movl	$0x3a03126f, 24(%rdi)
	ret
	.cfi_endproc
.LFE3694:
	.size	_ZN10pointLightC2Ev, .-_ZN10pointLightC2Ev
	.globl	_ZN10pointLightC1Ev
	.set	_ZN10pointLightC1Ev,_ZN10pointLightC2Ev
	.align 2
	.globl	_ZN10pointLightC2Efffiiif
	.type	_ZN10pointLightC2Efffiiif, @function
_ZN10pointLightC2Efffiiif:
.LFB3697:
	.cfi_startproc
	endbr64
	movl	%esi, 12(%rdi)
	movl	%edx, 16(%rdi)
	movl	%ecx, 20(%rdi)
	movss	%xmm0, (%rdi)
	movss	%xmm1, 4(%rdi)
	movss	%xmm2, 8(%rdi)
	movss	%xmm3, 24(%rdi)
	ret
	.cfi_endproc
.LFE3697:
	.size	_ZN10pointLightC2Efffiiif, .-_ZN10pointLightC2Efffiiif
	.globl	_ZN10pointLightC1Efffiiif
	.set	_ZN10pointLightC1Efffiiif,_ZN10pointLightC2Efffiiif
	.align 2
	.globl	_ZN10pointLightC2E5Pointiiif
	.type	_ZN10pointLightC2E5Pointiiif, @function
_ZN10pointLightC2E5Pointiiif:
.LFB3700:
	.cfi_startproc
	endbr64
	movl	%esi, 12(%rdi)
	movl	%edx, 16(%rdi)
	movl	%ecx, 20(%rdi)
	movq	%xmm0, (%rdi)
	movss	%xmm1, 8(%rdi)
	movss	%xmm2, 24(%rdi)
	ret
	.cfi_endproc
.LFE3700:
	.size	_ZN10pointLightC2E5Pointiiif, .-_ZN10pointLightC2E5Pointiiif
	.globl	_ZN10pointLightC1E5Pointiiif
	.set	_ZN10pointLightC1E5Pointiiif,_ZN10pointLightC2E5Pointiiif
	.align 2
	.globl	_ZN10pointLight8setColorEiii
	.type	_ZN10pointLight8setColorEiii, @function
_ZN10pointLight8setColorEiii:
.LFB3702:
	.cfi_startproc
	endbr64
	movl	%esi, 12(%rdi)
	movl	%edx, 16(%rdi)
	movl	%ecx, 20(%rdi)
	ret
	.cfi_endproc
.LFE3702:
	.size	_ZN10pointLight8setColorEiii, .-_ZN10pointLight8setColorEiii
	.align 2
	.globl	_ZN10pointLight8getColorEv
	.type	_ZN10pointLight8getColorEv, @function
_ZN10pointLight8getColorEv:
.LFB3703:
	.cfi_startproc
	endbr64
	cvtsi2ssl	16(%rdi), %xmm0
	cvtsi2ssl	12(%rdi), %xmm1
	movss	%xmm0, -16(%rsp)
	movss	%xmm1, -20(%rsp)
	cvtsi2ssl	20(%rdi), %xmm1
	movq	-20(%rsp), %xmm0
	ret
	.cfi_endproc
.LFE3703:
	.size	_ZN10pointLight8getColorEv, .-_ZN10pointLight8getColorEv
	.align 2
	.globl	_ZN10pointLight8setAtt_kEf
	.type	_ZN10pointLight8setAtt_kEf, @function
_ZN10pointLight8setAtt_kEf:
.LFB3704:
	.cfi_startproc
	endbr64
	movss	%xmm0, 24(%rdi)
	ret
	.cfi_endproc
.LFE3704:
	.size	_ZN10pointLight8setAtt_kEf, .-_ZN10pointLight8setAtt_kEf
	.align 2
	.globl	_ZN10pointLight8getAtt_kEv
	.type	_ZN10pointLight8getAtt_kEv, @function
_ZN10pointLight8getAtt_kEv:
.LFB3705:
	.cfi_startproc
	endbr64
	movss	24(%rdi), %xmm0
	ret
	.cfi_endproc
.LFE3705:
	.size	_ZN10pointLight8getAtt_kEv, .-_ZN10pointLight8getAtt_kEv
	.align 2
	.globl	_ZN10pointLight6setPosE5Point
	.type	_ZN10pointLight6setPosE5Point, @function
_ZN10pointLight6setPosE5Point:
.LFB3706:
	.cfi_startproc
	endbr64
	movq	%xmm0, (%rdi)
	movss	%xmm1, 8(%rdi)
	ret
	.cfi_endproc
.LFE3706:
	.size	_ZN10pointLight6setPosE5Point, .-_ZN10pointLight6setPosE5Point
	.align 2
	.globl	_ZN10pointLight6setPosEfff
	.type	_ZN10pointLight6setPosEfff, @function
_ZN10pointLight6setPosEfff:
.LFB3707:
	.cfi_startproc
	endbr64
	movss	%xmm0, (%rdi)
	movss	%xmm1, 4(%rdi)
	movss	%xmm2, 8(%rdi)
	ret
	.cfi_endproc
.LFE3707:
	.size	_ZN10pointLight6setPosEfff, .-_ZN10pointLight6setPosEfff
	.align 2
	.globl	_ZN10pointLight6getPosEv
	.type	_ZN10pointLight6getPosEv, @function
_ZN10pointLight6getPosEv:
.LFB3708:
	.cfi_startproc
	endbr64
	movss	8(%rdi), %xmm1
	movq	(%rdi), %xmm0
	ret
	.cfi_endproc
.LFE3708:
	.size	_ZN10pointLight6getPosEv, .-_ZN10pointLight6getPosEv
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3734:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3734:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#ifndef POINT_H
#define POINT_H

#include <hip/hip_runtime.h>

#include <iostream>
#include <cmath>
#include <float.h>

class Point 
{
    protected:
        float x, y, z;

    public:
        // Constructors
        __host__ __device__ Point();
        __host__ __device__ Point(float, float, float);

        // Accessors
        __host__ __device__ float X() {return this->x;} 
        __host__ __device__ float Y() {return this->y;} 
        __host__ __device__ float Z() {return this->z;} 
        
        // Mutators
        __host__ __device__ void setX(float X) {this->x = X;}      
        __host__ __device__ void setY(float Y) {this->y = Y;}
        __host__ __device__ void setZ(float Z) {this->z = Z;}
        __host__ __device__ void set(float X, float Y, float Z) 
        {
            this->x = X;
            this->y = Y;
            this->z = Z;
        }
        __host__ __device__ void set(Point p)
        {
            this->x = p.x;
            this->y = p.y;
            this->z = p.z;
        }

        // Other functions
        __host__ __device__ Point norm();
        __host__ __device__ float   dot(Point);
        __host__ __device__ Point cross(Point);
        __host__ __device__ float   dist(Point);
        __host__ __device__ Point cwiseMin(Point);

        // Operator overloads
        __host__ __device__ Point operator+ (Point);
        __host__ __device__ Point operator- (Point);
        __host__ __device__ Point operator/ (Point);
        __host__ __device__ Point operator* (Point);
        __host__ __device__ Point operator+=(Point);
        __host__ __device__ Point operator-=(Point);
        __host__ __device__ Point operator/=(Point);
        __host__ __device__ Point operator*=(Point);
        __host__ __device__ Point operator= (Point);
        __host__ __device__ bool    operator==(Point);

        __host__ __device__ Point operator+ (float);
        __host__ __device__ Point operator- (float);
        __host__ __device__ Point operator/ (float);
        __host__ __device__ Point operator* (float);
        __host__ __device__ Point operator+=(float);
        __host__ __device__ Point operator-=(float);
        __host__ __device__ Point operator/=(float);
        __host__ __device__ Point operator*=(float);
        
        __host__ friend std::ostream& operator<< (std::ostream&, Point);
};

// 3D ray class that inherits from point.
class Ray : public Point
{
    protected:
        float posx, posy, posz;
        int R, G, B; // Returned color value
        float t;     // time to closest object
    public:
        __host__ __device__ Ray();
        __host__ __device__ Ray(float, float, float, float, float, float);
        __host__ __device__ Ray(Point , Point);

        // Mutation functions
        __host__ __device__ void setColor(int, int, int);
        __host__ __device__ void setStart(Point );
        __host__ __device__ void setDir(Point );
        __host__ __device__ void setTime(float T) {this->t = T;}

        // Accessor functions
        __host__ __device__ float getR() {return this->R;}
        __host__ __device__ float getG() {return this->G;}
        __host__ __device__ float getB() {return this->B;}
        __host__ __device__ float getTime() {return this->t;}
        __host__ __device__ Point getStart() {return Point(this->posx, this->posy, this->posz);}
        __host__ __device__ Point getDir()   {return Point(this->x, this->y, this->z);}
        __host__ __device__ Point propagate(float);
};

// Point light source in 3D coordinates
class pointLight : public Point
{
    protected:
        int R, G, B;
        float attenuation_k;

    public:
        __host__ __device__ pointLight();
        __host__ __device__ pointLight(float, float, float, int, int, int, float);
        __host__ __device__ pointLight(Point, int, int, int, float);

        __host__ __device__ void    setColor(int, int, int);
        __host__ __device__ Point getColor();
        __host__ __device__ void    setAtt_k(float);
        __host__ __device__ float   getAtt_k();
        __host__ __device__ void    setPos(Point p);
        __host__ __device__ void    setPos(float, float, float);
        __host__ __device__ Point getPos();

};
#endif

	.text
	.file	"point.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_

	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
