Comments (5)
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.
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.
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.
Remember to do point.direction(other) instead of Direction::from((point, other)). See #93.
from hex_math.
Merged
from hex_math.
Related Issues (20)
- Make Point/etc a tuple struct, eliminate new() HOT 2
- Improve on HasValues, generics, etc.
- Make a CubePoint instead of Point::s()
- Consider making some newtype structs HOT 2
- Refactor the generic line() function HOT 2
- Combine range() and flood() HOT 9
- Maybe extract Predicate trait into a library HOT 2
- Make a line iterator HOT 3
- Convert denumerate() function into an iterator adapter
- Generic Point<T> instead of FloatPoint/etc HOT 1
- Implement Point functionality in a trait HOT 4
- Forgot to remove Predicate trait
- Travel should have specialized functions HOT 2
- Implement functions using Into instead of Borrow HOT 2
- Make a Vector(i32, i32, i32) newtype HOT 2
- Refactor base_ring implementation HOT 1
- Move line iterator, denumerate() out of traits::line HOT 1
- Separate line/ray into separate packages
- point.direction(other) instead of Direction::from((point, other))
- Make a prelude
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hex_math.