Coder Social home page Coder Social logo

Comments (5)

leftiness avatar leftiness commented on May 22, 2024

Or maybe instead of putting it on point, it should go on like HasValues since HasValues is what makes a struct interoperable with my functions. Or it could be a function like _.chain. chain(point).travel(5, east).distance(otherPoint);

from hex_math.

leftiness avatar leftiness commented on May 22, 2024

If I can make this happen, it'll really clean up a lot of code. It would let me chain simple transforms together, and I think it would even be possible to do into()/etc:

Point(1, 2, 5)
  .travel(Direction::East, 1)
  .rotate(Point(0, 0, 0), 1)
  .line_through(Point(1, 1, 1), 3);

Maybe it's too complicated, but a lazy evaluated version would be sick.

from hex_math.

leftiness avatar leftiness commented on May 22, 2024

Basically, travel() should be in a trait. Travel::travel(&self, Direction, distance: i32). impl<T, U> Travel<U> for T where T: Borrow<Point<U>>. Then I can self.borrow() to get an &Point which I can use to return a Point.

Apply the same concept to all of those functions. Distance, etc.

Then I'll be able to do my_point.travel().rotate().etc().

from hex_math.

leftiness avatar leftiness commented on May 22, 2024

Remember to do point.direction(other) instead of Direction::from((point, other)). See #93.

from hex_math.

leftiness avatar leftiness commented on May 22, 2024

Merged

from hex_math.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.