Comments (2)
/// Returns the angle associated with the provided hex [`Direction`].
///
/// Measured in radians counterclockwise from the +x axis.
pub fn angle(direction: Direction) -> f32 {
use Direction::*;
// See https://dr282zn36sxxg.cloudfront.net/datastreams/f-d%3Adff233ddd1e7e4c34a6545a8dfc1d63bbaf7eefbb40215febc633a30%2BIMAGE_TINY%2BIMAGE_TINY.1
PI / 6.
* match direction {
BottomRight => 11.,
TopRight => 1.,
Top => 3.,
TopLeft => 5.,
BottomLeft => 7.,
Bottom => 9.,
}
}
from hexx.
That would make a great addition !
As context there is a similar functionality in hex_layout computing the corners of hexagons, and I note that in your example the start_rotation
is missing (flat/pointy hexagons)
I think that the angle
method should be in HexLayout
or HexOrientation
to take the start_rotation
in account. Would that work for you ? Something like:
let layout = HexLayout::default();
let angle = layout.direction_angle(Direction::BottomRight);
and/ or
let orientation = HexOrientation::pointy();
let angle = orientation.direction_angle(Direction::BottomRight);
and / or
let orientation = HexOrientation::pointy();
let angle = Direction::BottomRight.angle(&orientation);
from hexx.
Related Issues (20)
- pointy_rectangle generates confusing results HOT 2
- Column mesh normals aren't normalized HOT 5
- `Direction` not consistent with bevy screen-space coordinates HOT 11
- Direction issues when using Pointy Orientation HOT 25
- `hexx v0.10.1` introduces breaking change for pre-rust `v1.71.0` HOT 3
- How to use ColorMesh2dBundle with textures HOT 1
- Mesh can be simplified
- Add mesh scale option
- Example showing how to use sprite sheet for animated tiles HOT 3
- Support irregular hexagons HOT 3
- Center pointy_rectangle to the window and field_of_movement input HOT 2
- field_of_movement algorithm is broken HOT 7
- Pathfinding algorithms should support costs for pairs of adjacent hexes rather than just hexes on their own. HOT 3
- Set orientation and fill area with hexagons HOT 2
- Mesh builders don't work well with offsetted HexLayout
- Fractional version of Hex and a variant in HexLayout for converting pixel to unrounded Hex HOT 5
- Visual artifacts when using sprites HOT 1
- Implement Eq/PartialEq on HexBounds
- Pointy Top and Flat Top EdgeDirections are swapped HOT 8
- Support heightmap mesh generation
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 hexx.