Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for possible enhancements #1

Open
Anras573 opened this issue Jun 3, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@Anras573
Copy link

commented Jun 3, 2019

Hi @simonech

Good to see someone else doing the ray tracer challenge with .NET CORE!

I have some suggestions if you don't mind :)

  1. Instead of creating a method called add, you can define an operator called + (same for -, /, *) like this:
public static Tupple operator +(Tupple left, Tupple right)  
{  
    return new Tupple(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);  
}

usage:

var t1 = new Tupple(1.0f, 1.0f, 1.0f, 1.0f);
var t2 = new Tupple(2.0f, 2.0f, 2.0f, 2.0f);
var sum = t1 + t2;
  1. I am not sure which version of .NET CORE you're using, but since 2.1 preview it has included a math library for float values

system.mathf

@simonech

This comment has been minimized.

Copy link
Owner

commented Jun 3, 2019

@Anras573

This comment has been minimized.

Copy link
Author

commented Jun 4, 2019

Btw, tuple is with one P :)

Now I have to do a search-and-replace throughout my code!

Glad I could help :)

@simonech simonech modified the milestones: Rework, After Chapter 2 Jun 5, 2019

@simonech simonech added the enhancement label Jun 5, 2019

@simonech simonech self-assigned this Jun 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.