diff --git a/Cargo.toml b/Cargo.toml index 9004e42..6d18211 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mikaboshi" -version = "0.7.0" +version = "0.8.0" edition = "2018" [dependencies] diff --git a/README.md b/README.md index 65eba8e..e3329f4 100644 --- a/README.md +++ b/README.md @@ -5,15 +5,15 @@ ## 1. About -__"mikaboshi"__ is a calculation library for Chinese astrology (written in Rust), -specifically, for _"Feng-Shui"_ (風水 or 风水). -The name __"mikaboshi"__ derives from a Marvel character +__"mikaboshi"__ is a calculation library for Chinese astrology (written in Rust) +specifically for _Feng-Shui_ (風水 or 风水). +The name _"mikaboshi"_ derives from a Marvel character ["Amatsu-Mikaboshi"](https://marvel.fandom.com/wiki/Amatsu-Mikaboshi_(Earth-616)), or one of the goddesses in Shinto myth. -"Amatsu-Mikaboshi" (アマツミカボシ), +_"Amatsu-Mikaboshi"_ (アマツミカボシ), when literally translated, means _"the shinning star in the sky"_. -Supported (Chinese astrological) concepts are: +Supported (Chinese astrological) calculations are: - [八卦 (Ba-Gua)](./docs/bagua.md) - [干支 (Gan-Zhi)](./docs/ganzhi.md) @@ -24,15 +24,15 @@ Supported (Chinese astrological) concepts are: This library depends on ["sowngwala"](https://github.com/minagawah/sowngwala/) -for calculating sun's position. -For both "mikaboshi" and "sowngwala" use +for calculating the sun's position. +For both _"mikaboshi"_ and _"sowngwala"_ use [chrono](https://crates.io/crates/chrono) for managing date & time. -You may have noticed many examples found in +You may have noticed many codes found in [samples](./docs/examples/index.md) are that of WASM apps. Yet, it does not mean you need WASM apps. -It is just that I happen to have a WASM app using the library, +It is just that I happen to have a WASM app using this library, and was easy for me to share the codes... __What Makes The Program Tricky?__ @@ -89,14 +89,18 @@ Each page provides general descriptions about what they are, and also provide some examples. You can also explore the actual codes for they contain a lot of _doc tests_. -### [八卦 (Bagua)](./docs/bagua.md) +### [八卦 (Ba-Gua)](./docs/bagua.md) -- [Bagua](./docs/bagua.md#baguabagua) -- [BaguaRawData](./docs/bagua.md#baguabaguarawdata) -- [BAGUA](./docs/bagua.md#baguabagua) -- [BAGUA_START_NORTH_INDEXES](./docs/bagua.md#baguabagua_start_north_indexes) -- [BAGUA_START_NORTH](./docs/bagua.md#baguabagua_start_north) -- [get_bagua_start_north](./docs/bagua.md#baguaget_bagua_start_north) +- [Gua](./docs/bagua.md#baguagua) +- [GuaRaw](./docs/bagua.md#baguaguaraw) +- [BAGUA_LO_SHU_ORDER_WITH_CENTER](./docs/bagua.md#baguabagua_lo_shu_order_with_center) +- [BAGUA_HE_TU_ORDER_INDEXES](./docs/bagua.md#baguabagua_he_tu_order_indexes) +- [BAGUA_HE_TU_ORDER](./docs/bagua.md#baguabagua_he_tu_order) +- [BAGUA_LO_SHU_ORDER_INDEXES](./docs/bagua.md#baguabagua_lo_shu_order_indexes) +- [BAGUA_LO_SHU_ORDER](./docs/bagua.md#baguabagua_lo_shu_order) +- [BAGUA_LO_SHU_COMPASS_ORDER_INDEXES](./docs/bagua.md#baguabagua_lo_shu_compass_order_indexes) +- [BAGUA_LO_SHU_COMPASS_ORDER](./docs/bagua.md#baguabagua_lo_shu_compass_order) +- [get_gua_compass_order](./docs/bagua.md#baguaget_gua_compass_order) ### [干支 (Gan-Zhi)](./docs/ganzhi.md) diff --git a/docs/bagua.md b/docs/bagua.md index b44637d..9f58432 100644 --- a/docs/bagua.md +++ b/docs/bagua.md @@ -1,19 +1,48 @@ -# 八卦 (Bagua) +# 八卦 (Ba-Gua) Source: [src/bagua.rs](../src/bagua.rs) ![sample_bagua](./sample_bagua.png) -Although 八卦 (Ba-Gua) is a concept in 易経 (I-Ching), -when used in Feng-Shui, it is often associated with 九星 (Jiu-Xing). -While everthing in this world is (said to be) divided into either 陰 (Yin) -or 陽 (Yang), each could be further divided into lesser Yin and Yang. -For Yang, some may be abundant in Yang. Or, some may slightly lean toward Yin. -This goes for Yin as well. Here, the initial Yin and Yang, -now divided into 4, or becomes 4 patterns. Then, for each, -there are further divisions, and for this time, it now makes it 8 patterns. -Ancient Chinese had a specific term for these 8 patterns, -and it is called, 八卦 (Ba-Gua), or "8 Gua". +八卦 (Ba-Gua) is a concept in 易経 (I-Ching) which is merely a concept +in fortune telling, but also appears frequently in a variety of +Chinese philosophy. "Gua" (卦) is a conventional unit which characterizes +certain aspects/qualities in life. "Ba" simply means "8" in Chinese. +So, "Ba-Gua" (八卦) tells that it consists of 8 卦 (Gua). To the eyes of +ancient Chinese, everything in this world was of either 陰 (Yin) or 陽 (Yang). +Or, you could say, the world is divided into 2. However, if you observe +more carefully, you notice some in Yang may slightly lean toward Yin, and +some in Yin toward Yang. So, you could probably have another division there, +for this time, divisions of 4. For greater Yang, you have lesser "Yin" +and "Yang", or you may call them, "Yang-Yang" and "Yang-Yin". Likewise, +for Yin, you will have "Yin-Yang" and "Yin-Yin". If you are brave enough, +you could repeat the process for the one last time. This time, you would +divide the world into 8. For ancient Chinese perceived the last division +of 8 being the basic building blocks for observing nature, and called +them, 八卦 (Ba-Gua) + +Now, when we say 八卦 (Ba-Gua), we usually refer to 2 different systems. +For the division just described above is called "先天八卦" (or +_"The Primordial Heaven"_), and a diagram to represent this order +is called "河圖" (He-Tu) (or 伏羲八卦 (Fu-Xi Ba-Gua)). Another one +is called "後天八卦" (or _"The Manifested Heaven"_), and its diagram +is called "洛書" (Lo-Shu) (or 文王八卦 (King Wen Ba-Gua)). +For the former illustrates the world of the original heaven, +and the latter, the manifested world (for which elements in nature +play active roles to produce gross material plane of our reality). + +Order of 河圖 (He-Tu) (for 先天八卦 _"The Primordial Heaven"_) + +[0] 乾 (Qian) +[1] 兌 (Dui) +[2] 離 (Li) +[3] 震 (Zhen) +[4] 巽 (Xun) +[5] 坎 (Kan) +[6] 坤 (Kun) +[7] 艮 (Gen) + +Order of 洛書 (Lo-Shu) (for 後天八卦 _"The Manifested Heaven"_) [0] 坎 (Kan) [1] 坤 (Kun) @@ -24,104 +53,168 @@ and it is called, 八卦 (Ba-Gua), or "8 Gua". [6] 艮 (Gen) [7] 離 (Li) +So, when we talk about 八卦 (Ba-Gua), we need to be specific about +which world we referring to. As you can see, there are 3 sets +of vectors defined in this program, namely: -## bagua::Bagua +- `BAGUA_HE_TU_ORDER` +- `BAGUA_LO_SHU_ORDER` +- `BAGUA_LO_SHU_ORDER_WITH_CENTER` + +Notice that the first 2 consists of 8 items, but the third one +consists of 9. When using 八卦 (Ba-Gua) for Feng-Shui, we usually +refer to 洛書 (Lo-Shu) diagram (which is `BAGUA_LO_SHU_ORDER`). +However, we usually plot 洛書 (Lo-Shu) into 9 boxes because it is +often associated with 九星 (Jiu-Xing) which requires not only +8 compass directions, but with an extra box in the middle. +So, in addition to 八卦 (Ba-Gua), when managing 洛書 (Lo-Shu) +for Feng-Shui, we need CENTER (or "中" (Zhong) in Chinese), +and that is what we have for `BAGUA_LO_SHU_ORDER_WITH_CENTER`. + +Also, notice of another vector defined in the program, namely, +`BAGUA_LO_SHU_COMPASS_ORDER`. This is a special vector for which +the order is _conceptually_ in "Lo-Shu" order, however, mapped +to 8 compass directions as each 卦 (Gua) plotted in clockwise manner. +This is specially useful when we have an app with a compass UI +because you can directly plot 卦 (Gua) out of this vector. + +## bagua::Gua A struct representing 卦 (Gua) and stores its attributes. ```rust #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Bagua { - pub num: u8, +pub struct Gua { pub name: Language, + pub jiuxing_num: u8, pub direction: String, pub element: u8, } ``` -## bagua::BaguaRawData +## bagua::GuaRaw -A temporary struct for loading JSON data when defining a static const `BAGUA`. +A temporary struct for loading JSON data when defining +a various vectors for 八卦 (Ba-Gua). ```rust #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BaguaRawData { - pub num: u8, +pub struct GuaRaw { pub name: LanguageData, + pub jiuxing_num: u8, pub direction: String, pub element: u8, } ``` -## bagua::BAGUA +## bagua::BAGUA_LO_SHU_ORDER_WITH_CENTER -`Vec` +`Vec` -A static vector with 9 items, each represents 卦 (Gua) of 八卦 (Ba-Gua), -or what known as "Eight Trigrams". Each stores associated attributes -for the 卦 (Gua), and are in the order of Ba-Gua Numbers. For instance, -坎 (Kan) is the first in Ba-Gua, so it comes first in the vector. -However, be careful when you refer to each 卦 (Gua) as the program -refers 卦 (Gua) not by Ba-Gua Numbers, but by vector indexes. -For 坎 (Kan), for instance, while it has the Ba-Gua Number of 1, -it is referred as 0 because that is the index is for 坎 (Kan). +This is a vector for 八卦 (Ba-Gua) with 9 items where the 5th item +being "中" (Zhong). By having 9 items instead of 8, it can be +directly mapped to 9 stars of 九星 (Jiu-Xing). Since 九星 (Jiu-Xing) +is mapped in "Lo-Shu" (洛書) order, so is this vector. +Check out the attribute `jiuxing_num` for each data, and you will +notice it corresponds to the Jiu-Xing number. + +八卦 (Ba-Gua) in "Lo-Shu" (洛書) order with 中 (Zhong) in the middle: + +[0] 坎 (Kan) -> No. 1 +[1] 坤 (Kun) -> No. 2 +[2] 震 (Zhen) -> No. 3 +[3] 巽 (Xun) -> No. 4 +[4] 中 (Zhong) -> No. 5 +[5] 乾 (Qian) -> No. 6 +[6] 兌 (Dui) -> No. 7 +[7] 艮 (Gen) -> No. 8 +[8] 離 (Li) -> No. 9 -[0] 坎 (1 = Kan) -[1] 坤 (2 = Kun) -[2] 震 (3 = Zhen) -[3] 巽 (4 = Xun) -[4] 中 (5 = Zhong) -[5] 乾 (6 = Qian) -[6] 兌 (7 = Dui) -[7] 艮 (8 = Gen) -[8] 離 (9 = Li) - For attributes details stored in the vector is found in JSON file: -[json/bagua.json](../json/bagua.json) +`src/json/bagua.json` -## bagua::BAGUA_START_NORTH_INDEXES +## bagua::BAGUA_HE_TU_ORDER_INDEXES + +`Vec` + +[INDEX] 八卦 (Ba-Gua) in "He-Tu" (河圖) order. + +## bagua::BAGUA_HE_TU_ORDER + +`Vec` + +[ACTUAL DATA] 八卦 (Ba-Gua) in "He-Tu" (河圖) order. + +[0] 乾 (Qian) +[1] 兌 (Dui) +[2] 離 (Li) +[3] 震 (Zhen) +[4] 巽 (Xun) +[5] 坎 (Kan) +[6] 坤 (Kun) +[7] 艮 (Gen) + +## bagua::BAGUA_LO_SHU_ORDER_INDEXES `Vec` -Another static vector for 八卦 (Ba-Gua) (and is `Vec`). -However, this time, it has only 8 items because this is used -for compass rotation. When using a compass, only 8 directions matter, -and the middle does not mean anything. When 八卦 (Ba-Gua) are -placed in 洛書 (Lo-Shu) order, 中 (Zhong) comes in the middle. -So, 中 (Zhong) is missing for this vector. For 八卦 (Ba-Gua), -it begins with 坎 (Kan) which resides in the north -when they are placed in Lo-Shu order. Moving clockwise, -what you see next in the north-east, is 艮 (Gen). -Then, comes 震 (3 = Zhen) which is in the east, and, so on. +[INDEX] 八卦 (Ba-Gua) in "Lo-Shu" (洛書) order. -[0] 坎 (1 = Kan) -[1] 艮 (8 = Gen) -[2] 震 (3 = Zhen) -[3] 巽 (4 = Xun) -[4] 離 (9 = Li) -[5] 坤 (2 = Kun) -[6] 兌 (7 = Dui) -[7] 乾 (6 = Qian) +## bagua::BAGUA_LO_SHU_ORDER -## bagua::BAGUA_START_NORTH +`Vec` + +[ACTUAL DATA] 八卦 (Ba-Gua) in "Lo-Shu" (洛書) order. -`Vec` +[0] 坎 (Kan) +[1] 艮 (Gen) +[2] 震 (Zhen) +[3] 巽 (Xun) +[4] 離 (Li) +[5] 坤 (Kun) +[6] 兌 (Dui) +[7] 乾 (Qian) -While the order is the same as `BAGUA_START_NORTH_INDEXES`, -for this time, it is `Vec` instead of `Vec`. +## bagua::BAGUA_LO_SHU_COMPASS_ORDER_INDEXES -## bagua::get_bagua_start_north +`Vec` -A getter for `BAGUA_START_NORTH`. +[INDEX] 八卦 (Ba-Gua) in "Lo-Shu" order, however, mapped to 8 compass directions. + +## bagua::BAGUA_LO_SHU_COMPASS_ORDER + +`Vec` + +[ACTUAL DATA] 八卦 (Ba-Gua) in "Lo-Shu" order, however, mapped to 8 compass directions. +When "Lo-Shu" (洛書) order is mapped to 8 compass directions, it is convenient +to have a vector which starts with 卦 (Gua) for _"NORTH"_ which is "坎" (Kan). +Likewise, we want the second item being 卦 (Gua) for _"NORTH EAST"_ which is "艮" (Gen). +For the third item, likewise, for _"EAST"_ or "震" (Zhen). + +八卦 (Ba-Gua) in "Lo-Shu" order mapped to 8 directions (starting NORTH): + +[0] 坎 (Kan)-> N +[1] 艮 (Gen)-> NE +[2] 震 (Zhen)-> E +[3] 巽 (Xun)-> SE +[4] 離 (Li)-> S +[5] 坤 (Kun)-> SW +[6] 兌 (Dui)-> W +[7] 乾 (Qian)-> NW + + +## bagua::get_gua_compass_order + +A getter for `BAGUA_LO_SHU_COMPASS_ORDER`. Example: ```rust -use mikaboshi::bagua::{get_bagua_start_north, Bagua}; +use mikaboshi::bagua::{get_gua_compass_order, Gua}; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn xx(index: usize) -> JsValue { - let bagua: Option<&Bagua> = get_bagua_start_north(index); - JsValue::from_serde(&bagua).unwrap() + let gua: Option<&Gua> = get_gua_compass_order(index); + JsValue::from_serde(&gua).unwrap() } ``` diff --git a/docs/examples/Cargo.toml b/docs/examples/Cargo.toml index ea2da85..cdc2a53 100644 --- a/docs/examples/Cargo.toml +++ b/docs/examples/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib", "rlib"] chrono = "0.4.19" console_error_panic_hook = "^0.1.6" js-sys = "0.3.52" -mikaboshi = { git = "https://github.com/minagawah/mikaboshi", version = "0.6.0" } +mikaboshi = { git = "https://github.com/minagawah/mikaboshi", version = "0.8.0" } serde = { version = "1.0.127", features = ["derive"] } wasm-bindgen = { version = "0.2.70", features = ["serde-serialize"] } diff --git a/docs/examples/FengShui.js b/docs/examples/FengShui.js index f389fd2..05f0ed0 100644 --- a/docs/examples/FengShui.js +++ b/docs/examples/FengShui.js @@ -22,7 +22,7 @@ import React, { import moment from 'moment'; import init, { // 八卦 (Ba-Gua) - get_bagua_start_north as wasm_get_bagua_start_north, + get_gua_compass_order as wasm_get_gua_compass_order, // 二十四山向 (Er-Shi Si-Shan Xiang) get_twentyfour_direction_from_index as wasm_get_twentyfour_direction_from_index, get_twentyfour_direction_from_degrees as wasm_get_twentyfour_direction_from_degrees, @@ -53,8 +53,6 @@ const WASM_PATH = ? 'wasm/voi-feng-shui/voi-feng-shui_bg.wasm' : void 0; -// console.log('[useFengShui] WASM_PATH: ', WASM_PATH); - const DATETIME_KEYS = Object.keys(DATETIME_FORMAT); const DATE_KEYS = DATETIME_KEYS.filter( key => @@ -81,7 +79,7 @@ export const has_valid_profile = (p = {}) => * @property {Object} shan_xing * @property {Object} xiang_xing * @property {Function} update - * @property {FengShui.FengShuiContext.get_bagua_start_north} + * @property {FengShui.FengShuiContext.get_gua_compass_order} * @property {FengShui.FengShuiContext.get_direction_positions_in_chart} - NOT IN USE * @property {FengShui.FengShuiContext.get_opposite_direction} - NOT IN USE * @property {FengShui.FengShuiContext.get_twentyfour_direction_from_index} @@ -107,7 +105,7 @@ const FengShuiContext = createContext({ update: noop, // 八卦 (Ba-Gua) - get_bagua_start_north: noop, + get_gua_compass_order: noop, // 二十四山向 (Er-Shi Si-Shan Xiang) get_twentyfour_direction_from_index: noop, @@ -151,16 +149,16 @@ export const FengShuiProvider = props => { /** * A simple accessor for values stored in `BAGUA_START_NORTH`. - * @typedef FengShui.FengShuiContext.get_bagua_start_north + * @typedef FengShui.FengShuiContext.get_gua_compass_order * @function */ /** - * @type {FengShui.FengShuiContext.get_bagua_start_north} + * @type {FengShui.FengShuiContext.get_gua_compass_order} */ - const get_bagua_start_north = useCallback( + const get_gua_compass_order = useCallback( dir => { - return ready && wasm_get_bagua_start_north(dir); + return ready && wasm_get_gua_compass_order(dir); }, [ready] ); @@ -481,7 +479,7 @@ export const FengShuiProvider = props => { shan_xing, xiang_xing, update, - get_bagua_start_north, + get_gua_compass_order, get_twentyfour_direction_from_index, get_twentyfour_direction_from_degrees, get_twentyfour_data_from_index, @@ -528,13 +526,9 @@ export const useFengShuiSync = () => { if (p) { const t = p.localtime.format('YYYY-MM-DD'); const dir = `${p.direction}${p.sector}`; - // console.log(`[FengShuiContext] (useFengShuiSync) localtime: ${t}`); - // console.log(`[FengShuiContext] (useFengShuiSync) dir: ${dir}`); - setHasProfile(true); update(p); } else { - // console.log('[FengShuiContext] No valid profiles...'); setHasProfile(false); } }, [ready, profiles]); diff --git a/docs/examples/bagua_info.jsx b/docs/examples/bagua_info.jsx index 96d72f0..4c98b61 100644 --- a/docs/examples/bagua_info.jsx +++ b/docs/examples/bagua_info.jsx @@ -31,7 +31,7 @@ const fix3 = fixed(3); export const FengShuiBaguaInfo = () => { const { worldInfo: world } = useWorld(); const deviceOrientation = useDeviceOrientation(); - const { ready, get_bagua_start_north } = useFengShui(); + const { ready, get_gua_compass_order } = useFengShui(); const [boxes, setBoxes] = useState([]); @@ -78,7 +78,7 @@ export const FengShuiBaguaInfo = () => { if (ready) { setBoxes( [...new Array(8)].map((_, index) => { - const bagua = get_bagua_start_north(index); + const bagua = get_gua_compass_order(index); const name = bagua?.name; return name ? { diff --git a/docs/examples/lib.rs b/docs/examples/lib.rs index 3fcc90b..66c6ad5 100644 --- a/docs/examples/lib.rs +++ b/docs/examples/lib.rs @@ -3,7 +3,7 @@ extern crate chrono; use chrono::Datelike; use chrono::naive::NaiveDate; -use mikaboshi::bagua::{get_bagua_start_north as _bagua_start_north, Bagua}; +use mikaboshi::bagua::{get_gua_compass_order as _gua_compass_order, Gua}; use mikaboshi::compass::{ get_direction_positions_in_chart as _direction_positions_in_chart, get_opposite_direction as _opposite_direction, @@ -52,13 +52,13 @@ pub fn main() { } // ================================================================ -// 八卦 (Bagua) +// 八卦 (Gua) // ================================================================ #[wasm_bindgen] -pub fn get_bagua_start_north(index: usize) -> JsValue { - let bagua: Option<&Bagua> = _bagua_start_north(index); - JsValue::from_serde(&bagua).unwrap() +pub fn get_gua_compass_order(index: usize) -> JsValue { + let gua: Option<&Gua> = _gua_compass_order(index); + JsValue::from_serde(&gua).unwrap() } // ================================================================ @@ -97,7 +97,7 @@ pub fn get_twentyfour_direction_from_index(index: usize) -> JsValue { pub fn get_twentyfour_data_from_index(index: usize) -> JsValue { let t_type: TwentyFourType = _twentyfour_data_from_index(index); match t_type { - TwentyFourType::Bagua(bagua) => JsValue::from_serde(bagua).unwrap(), + TwentyFourType::Gua(gua) => JsValue::from_serde(gua).unwrap(), TwentyFourType::Stem(stem) => JsValue::from_serde(stem).unwrap(), TwentyFourType::Branch(branch) => JsValue::from_serde(branch).unwrap(), } @@ -113,7 +113,7 @@ pub fn get_twentyfour_direction_from_degrees(degrees: f32) -> JsValue { pub fn get_twentyfour_data_from_direction(direction: &str, sector: usize) -> JsValue { let t_type: TwentyFourType = _twentyfour_data_from_direction(direction, sector); match t_type { - TwentyFourType::Bagua(bagua) => JsValue::from_serde(bagua).unwrap(), + TwentyFourType::Gua(gua) => JsValue::from_serde(gua).unwrap(), TwentyFourType::Stem(stem) => JsValue::from_serde(stem).unwrap(), TwentyFourType::Branch(branch) => JsValue::from_serde(branch).unwrap(), } diff --git a/docs/jiuxing.md b/docs/jiuxing.md index 8e70326..2b94837 100644 --- a/docs/jiuxing.md +++ b/docs/jiuxing.md @@ -2,57 +2,53 @@ Source: [src/jiuxing.rs](../src/jiuxing.rs) -At the beginning, the law governing the universe was simple. -Yet, as man acquired the faculty of thought, was it no longer so. -It was not the universe which changed, but was about how man began -to see the universe differently. Thought, after all, is nothing -but reflections of the outer world. In another word, the outer -world we perceive could only be understood via patterns -that are innate to man's thought. Just like "Malkuth" in _Kabbalha_ -is about both the earthly kingdom and the man himself, -as ancient Chinese attempted describing patterns in the universe, -they introduced another artificial element "metal" -(or "earth" when it is deployed in actual reality). -For the ancient Chinese, the former is called -先天八卦 ("the Primordial Heaven"), and the latter, -後天八卦 ("the Manifested Heaven"). -To study the patterns peculiar to each universe, a conventional -board with 8 directions and 1 in the center has been in use, -where "8 Gua" (八卦) are assigned for slots on the board. -However, for many 風水 (Feng-Shui) systems, we are normally -dealing with the latter, or 後天八卦 ("the Manifested Heaven"). +九星 (Jiu-Xing) means "9 stars" in Chinese. +In 風水 (Feng-Shui), 9 boxes are drawn to represent +the spatial condition of the place in concern. +The box in the middle represents where you are, +and 8 boxes which surrounding the middle represent +8 compass directions. For these 9 boxes, plotted +special symbols, each of which is called, a "Star" (星). +When we say 九星 (Jiu-Xing) in Chinese, "Jiu" means "9", +and "Xing" means a "Star". While 九星 (Jiu-Xing) +has fixed positions (associated with 洛書 (Lo-Shu)), +they change positions over time, and this movement +is called 飞泊 (Fei-Po) or "flying" because of how it +appears to our eyes when they move. +//! +As explained in 八卦 (Ba-Gua) (see: `src/bagua.rs`), +there are 2 worldly systems concerned, namely, +先天八卦 (or "the Primordial Heaven") and +後天八卦 (or "the Manifested Heaven"), and we deal +with the latter system when we talk about 風水 (Feng-Shui). -For 後天八卦 ("the Manifested Heaven") has a specific name -in 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui), and is called -地盤 (Di-Pan). However, there are 3 more boards in -玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui) -in addition to 地盤 (Di-Pan), namely: +In 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui), there is +a special name given to the latter system, and is called, +地盤 (Di-Pan). "Di" means "earth", and "Pan" means "board". +So, it is basically a board which is drawn at the bottom +of any Feng-Shui charts. On 地盤 (Di-Pan), 九星 (Jiu-Xing) +are plotted for which the order is fundamentally that of +洛書 (Lo-Shu) order in 八卦 (Ba-Gua). However, they move +(or "fly") over 地盤 (Di-Pan) as time goes. +In 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui), there are +3 other boards that are drawn on top of 地盤 (Di-Pan), namely: -(1) 運盤 (Un-Pan) (or 天盤 (Tien-Pan)) -(2) 山星 (Shan-Xing) -(3) 向星 (Xiang-Xing) +- 運盤 (Un-Pan) or 天盤 (Tien-Pan) +- 山星 (Shan-Xing) +- 向星 (Xiang-Xing) -In practice, for all the above 3 boards, 九星 (Jiu-Xing) -or "the Nine Stars" are assigned. While "8 Gua" (八卦) -has fixed positions, 九星 (Jiu-Xing) changes -over time for spatial constraints given. -When their positions change, the movement is called -飞泊 (Fei-Po) or "flying" because of how it appears -to our eyes when they move. - -For the first board 運盤 (Un-Pan), positions of 九星 (Jiu-Xing) -are determined by building's construction year, -and calculated based on 三元九運 (Sang-Yuan Jiu-Yun) +For 運盤 (Un-Pan), positions of 九星 (Jiu-Xing) are determined +by construction year for the building in concern which is +calculated based on 三元九運 (Sang-Yuan Jiu-Yun), or "9 Yearly Cycles". We could say that 運盤 (Un-Pan) -essentially describes of the temporal aspect of the building -For 山星 (Shan-Xing) and 向星 (Xiang-Xing) are determined -by spatial aspects of the building, though, temporal aspects -are also associated indirectly in calculations. +essentially describes the temporal aspect. +山星 (Shan-Xing) and 向星 (Xiang-Xing) are determined +by spatial aspects of the building (however, in actual +calculations, some temporal aspects comes in). -When 運盤 (Un-Pan), 山星 (Shan-Xing), and 向星 (Xiang-Xing) -are added to 地盤 (Di-Pan) at the bottom, it is called -下卦図 (Xia-Gua-Tu), or simply referred as -飞星図 (Fei-Xing-Tu; "the Flying Star Chart"). +When these 3 extra boards are placed on top of 地盤 (Di-Pan), +the whole thing is called, 下卦図 (Xia-Gua-Tu), or simply +referred as 飞星図 (Fei-Xing-Tu), or "The Flying Star Chart". Jiu-Xing (九星): diff --git a/json/bagua.json b/json/bagua.json index c41dffb..89a52a8 100644 --- a/json/bagua.json +++ b/json/bagua.json @@ -1,6 +1,5 @@ [ { - "num": 1, "name": { "en": "kan", "zh_cn": ["坎", "kǎn"], @@ -8,11 +7,11 @@ "ja": ["かん", "kan"], "vi": [] }, + "jiuxing_num": 1, "direction": "n", "element": 4 }, { - "num": 2, "name": { "en": "kun", "zh_cn": ["坤", "kūn"], @@ -20,11 +19,11 @@ "ja": ["こん", "kon"], "vi": [] }, + "jiuxing_num": 2, "direction": "sw", "element": 2 }, { - "num": 3, "name": { "en": "zhen", "zh_cn": ["震", "zhèn"], @@ -32,11 +31,11 @@ "ja": ["しん", "shin"], "vi": [] }, + "jiuxing_num": 3, "direction": "e", "element": 0 }, { - "num": 4, "name": { "en": "xun", "zh_cn": ["巽", "xùn"], @@ -44,11 +43,11 @@ "ja": ["そん", "son"], "vi": [] }, + "jiuxing_num": 4, "direction": "se", "element": 0 }, { - "num": 5, "name": { "en": "zhong", "zh_cn": ["中", "zhōng"], @@ -56,11 +55,11 @@ "ja": ["中", "chu"], "vi": [] }, + "jiuxing_num": 5, "direction": "", "element": 2 }, { - "num": 6, "name": { "en": "qian", "zh_cn": ["乾", "qián"], @@ -68,11 +67,11 @@ "ja": ["けん", "ken"], "vi": [] }, + "jiuxing_num": 6, "direction": "nw", "element": 3 }, { - "num": 7, "name": { "en": "dui", "zh_cn": ["兌", "duì"], @@ -80,11 +79,11 @@ "ja": ["だ", "da"], "vi": [] }, + "jiuxing_num": 7, "direction": "e", "element": 3 }, { - "num": 8, "name": { "en": "gen", "zh_cn": ["艮", "gèn"], @@ -92,11 +91,11 @@ "ja": ["ごん", "gon"], "vi": [] }, + "jiuxing_num": 8, "direction": "ne", "element": 2 }, { - "num": 9, "name": { "en": "li", "zh_cn": ["離", "lí"], @@ -104,6 +103,7 @@ "ja": ["り", "ri"], "vi": [] }, + "jiuxing_num": 9, "direction": "s", "element": 1 } diff --git a/src/bagua.rs b/src/bagua.rs index 58764a2..21efd82 100644 --- a/src/bagua.rs +++ b/src/bagua.rs @@ -1,14 +1,43 @@ -//! Although 八卦 (Ba-Gua) is a concept in 易経 (I-Ching), -//! when used in Feng-Shui, it is often associated with 九星 (Jiu-Xing). -//! While everthing in this world is (said to be) divided into either 陰 (Yin) -//! or 陽 (Yang), each could be further divided into lesser Yin and Yang. -//! For Yang, some may be abundant in Yang. Or, some may slightly lean toward Yin. -//! This goes for Yin as well. Here, the initial Yin and Yang, -//! now divided into 4, or becomes 4 patterns. Then, for each, -//! there are further divisions, and for this time, it now makes it 8 patterns. -//! Ancient Chinese had a specific term for these 8 patterns, -//! and it is called, 八卦 (Ba-Gua), or "8 Gua". -//! +//! 八卦 (Ba-Gua) is a concept in 易経 (I-Ching) which is merely a concept +//! in fortune telling, but also appears frequently in a variety of +//! Chinese philosophy. "Gua" (卦) is a conventional unit which characterizes +//! certain aspects/qualities in life. "Ba" simply means "8" in Chinese. +//! So, "Ba-Gua" (八卦) tells that it consists of 8 卦 (Gua). To the eyes of +//! ancient Chinese, everything in this world was of either 陰 (Yin) or 陽 (Yang). +//! Or, you could say, the world is divided into 2. However, if you observe +//! more carefully, you notice some in Yang may slightly lean toward Yin, and +//! some in Yin toward Yang. So, you could probably have another division there, +//! for this time, divisions of 4. For greater Yang, you have lesser "Yin" +//! and "Yang", or you may call them, "Yang-Yang" and "Yang-Yin". Likewise, +//! for Yin, you will have "Yin-Yang" and "Yin-Yin". If you are brave enough, +//! you could repeat the process for the one last time. This time, you would +//! divide the world into 8. For ancient Chinese perceived the last division +//! of 8 being the basic building blocks for observing nature, and called +//! them, 八卦 (Ba-Gua) +//! +//! Now, when we say 八卦 (Ba-Gua), we usually refer to 2 different systems. +//! For the division just described above is called "先天八卦" (or +//! _"The Primordial Heaven"_), and a diagram to represent this order +//! is called "河圖" (He-Tu) (or 伏羲八卦 (Fu-Xi Ba-Gua)). Another one +//! is called "後天八卦" (or _"The Manifested Heaven"_), and its diagram +//! is called "洛書" (Lo-Shu) (or 文王八卦 (King Wen Ba-Gua)). +//! For the former illustrates the world of the original heaven, +//! and the latter, the manifested world (for which elements in nature +//! play active roles to produce gross material plane of our reality). +//! +//! Order of 河圖 (He-Tu) (for 先天八卦 _"The Primordial Heaven"_) +//! +//! [0] 乾 (Qian) +//! [1] 兌 (Dui) +//! [2] 離 (Li) +//! [3] 震 (Zhen) +//! [4] 巽 (Xun) +//! [5] 坎 (Kan) +//! [6] 坤 (Kun) +//! [7] 艮 (Gen) +//! +//! Order of 洛書 (Lo-Shu) (for 後天八卦 _"The Manifested Heaven"_) +//! //! [0] 坎 (Kan) //! [1] 坤 (Kun) //! [2] 震 (Zhen) @@ -17,6 +46,32 @@ //! [5] 兌 (Dui) //! [6] 艮 (Gen) //! [7] 離 (Li) +//! +//! So, when we talk about 八卦 (Ba-Gua), we need to be specific about +//! which world we referring to. As you can see, there are 3 sets +//! of vectors defined in this program, namely: +//! +//! - `BAGUA_HE_TU_ORDER` +//! - `BAGUA_LO_SHU_ORDER` +//! - `BAGUA_LO_SHU_ORDER_WITH_CENTER` +//! +//! Notice that the first 2 consists of 8 items, but the third one +//! consists of 9. When using 八卦 (Ba-Gua) for Feng-Shui, we usually +//! refer to 洛書 (Lo-Shu) diagram (which is `BAGUA_LO_SHU_ORDER`). +//! However, we usually plot 洛書 (Lo-Shu) into 9 boxes because it is +//! often associated with 九星 (Jiu-Xing) which requires not only +//! 8 compass directions, but with an extra box in the middle. +//! So, in addition to 八卦 (Ba-Gua), when managing 洛書 (Lo-Shu) +//! for Feng-Shui, we need CENTER (or "中" (Zhong) in Chinese), +//! and that is what we have for `BAGUA_LO_SHU_ORDER_WITH_CENTER`. +//! +//! Also, notice of another vector defined in the program, namely, +//! `BAGUA_LO_SHU_COMPASS_ORDER`. This is a special vector for which +//! the order is _conceptually_ in "Lo-Shu" order, however, mapped +//! to 8 compass directions as each 卦 (Gua) plotted in clockwise manner. +//! This is specially useful when we have an app with a compass UI +//! because you can directly plot 卦 (Gua) out of this vector. + use serde::{Deserialize, Serialize}; use crate::language::{ @@ -33,117 +88,151 @@ use crate::utils::{ /// A struct representing 卦 (Gua) and stores its attributes. #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Bagua { - pub num: u8, +pub struct Gua { pub name: Language, + pub jiuxing_num: u8, pub direction: String, pub element: u8, } -/// A temporary struct for loading JSON data when defining a static const `BAGUA`. +/// A temporary struct for loading JSON data when defining +/// a various vectors for 八卦 (Ba-Gua). #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BaguaRawData { - pub num: u8, +pub struct GuaRaw { pub name: LanguageData, + pub jiuxing_num: u8, pub direction: String, pub element: u8, } -impl LanguageTrait for Bagua { +impl LanguageTrait for Gua { fn name(&self) -> Box { Box::new(self.name.clone()) } } -impl NameDataTrait for BaguaRawData { +impl NameDataTrait for GuaRaw { fn name(&self) -> Box { Box::new(self.name.clone()) } } lazy_static! { - /// A static vector with 9 items, each represents 卦 (Gua) of 八卦 (Ba-Gua), - /// or what known as "Eight Trigrams". Each stores associated attributes - /// for the 卦 (Gua), and are in the order of Ba-Gua Numbers. For instance, - /// 坎 (Kan) is the first in Ba-Gua, so it comes first in the vector. - /// However, be careful when you refer to each 卦 (Gua) as the program - /// refers 卦 (Gua) not by Ba-Gua Numbers, but by vector indexes. - /// For 坎 (Kan), for instance, while it has the Ba-Gua Number of 1, - /// it is referred as 0 because that is the index is for 坎 (Kan). + /// This is a vector for 八卦 (Ba-Gua) with 9 items where the 5th item + /// being "中" (Zhong). By having 9 items instead of 8, it can be + /// directly mapped to 9 stars of 九星 (Jiu-Xing). Since 九星 (Jiu-Xing) + /// is mapped in "Lo-Shu" (洛書) order, so is this vector. + /// Check out the attribute `jiuxing_num` for each data, and you will + /// notice it corresponds to the Jiu-Xing number. /// - /// [0] 坎 (1 = Kan) - /// [1] 坤 (2 = Kun) - /// [2] 震 (3 = Zhen) - /// [3] 巽 (4 = Xun) - /// [4] 中 (5 = Zhong) - /// [5] 乾 (6 = Qian) - /// [6] 兌 (7 = Dui) - /// [7] 艮 (8 = Gen) - /// [8] 離 (9 = Li) + /// 八卦 (Ba-Gua) in "Lo-Shu" (洛書) order with 中 (Zhong) in the middle: + /// + /// [0] 坎 (Kan) -> No. 1 + /// [1] 坤 (Kun) -> No. 2 + /// [2] 震 (Zhen) -> No. 3 + /// [3] 巽 (Xun) -> No. 4 + /// [4] 中 (Zhong) -> No. 5 + /// [5] 乾 (Qian) -> No. 6 + /// [6] 兌 (Dui) -> No. 7 + /// [7] 艮 (Gen) -> No. 8 + /// [8] 離 (Li) -> No. 9 /// /// For attributes details stored in the vector is found in JSON file: /// `src/json/bagua.json` - pub static ref BAGUA: Vec = { + pub static ref BAGUA_LO_SHU_ORDER_WITH_CENTER: Vec = { let json = &include_str!("../json/bagua.json"); - let data: Vec = get_json::(json); + let data: Vec = get_json::(json); data.iter().map(|item| { let item = item.clone(); - Bagua { - num: item.num, + Gua { name: item.language_from_data(), direction: item.direction, + jiuxing_num: item.jiuxing_num, element: item.element, } }).collect() }; - /// Another static vector for 八卦 (Ba-Gua) (and is `Vec`). - /// However, this time, it has only 8 items because this is used - /// for compass rotation. When using a compass, only 8 directions matter, - /// and the middle does not mean anything. When 八卦 (Ba-Gua) are - /// placed in 洛書 (Lo-Shu) order, 中 (Zhong) comes in the middle. - /// So, 中 (Zhong) is missing for this vector. For 八卦 (Ba-Gua), - /// it begins with 坎 (Kan) which resides in the north - /// when they are placed in Lo-Shu order. Moving clockwise, - /// what you see next in the north-east, is 艮 (Gen). - /// Then, comes 震 (3 = Zhen) which is in the east, and, so on. - /// Note that it is `Vec`, and not `Vec`. - /// - /// [0] 坎 (1 = Kan) - /// [1] 艮 (8 = Gen) - /// [2] 震 (3 = Zhen) - /// [3] 巽 (4 = Xun) - /// [4] 離 (9 = Li) - /// [5] 坤 (2 = Kun) - /// [6] 兌 (7 = Dui) - /// [7] 乾 (6 = Qian) - pub static ref BAGUA_START_NORTH_INDEXES: Vec = vec![0, 7, 2, 3, 8, 1, 6, 5]; + /// [INDEX] 八卦 (Ba-Gua) in "He-Tu" (河圖) order. + pub static ref BAGUA_HE_TU_ORDER_INDEXES: Vec = vec![0, 1, 2, 3, 5, 6, 7, 8]; - /// The order is the same as `BAGUA_START_NORTH_INDEXES`, - /// however, it is not `Vec` but `Vec` for this time. - pub static ref BAGUA_START_NORTH: Vec = make_sort( - BAGUA_START_NORTH_INDEXES.to_vec() + /// [ACTUAL DATA] 八卦 (Ba-Gua) in "He-Tu" (河圖) order. + /// + /// [0] 乾 (Qian) + /// [1] 兌 (Dui) + /// [2] 離 (Li) + /// [3] 震 (Zhen) + /// [4] 巽 (Xun) + /// [5] 坎 (Kan) + /// [6] 坤 (Kun) + /// [7] 艮 (Gen) + pub static ref BAGUA_HE_TU_ORDER: Vec = make_sort( + BAGUA_HE_TU_ORDER_INDEXES.to_vec() // order )( - BAGUA.to_vec() + BAGUA_LO_SHU_ORDER_WITH_CENTER.to_vec() // data source + ); + + /// [INDEX] 八卦 (Ba-Gua) in "Lo-Shu" (洛書) order. + pub static ref BAGUA_LO_SHU_ORDER_INDEXES: Vec = vec![0, 1, 2, 3, 5, 6, 7, 8]; + + /// [ACTUAL DATA] 八卦 (Ba-Gua) in "Lo-Shu" (洛書) order. + /// + /// [0] 坎 (Kan) + /// [1] 艮 (Gen) + /// [2] 震 (Zhen) + /// [3] 巽 (Xun) + /// [4] 離 (Li) + /// [5] 坤 (Kun) + /// [6] 兌 (Dui) + /// [7] 乾 (Qian) + pub static ref BAGUA_LO_SHU_ORDER: Vec = make_sort( + BAGUA_LO_SHU_ORDER_INDEXES.to_vec() // order + )( + BAGUA_LO_SHU_ORDER_WITH_CENTER.to_vec() // data source + ); + + /// [INDEX] 八卦 (Ba-Gua) in "Lo-Shu" order, however, mapped to 8 compass directions. + pub static ref BAGUA_LO_SHU_COMPASS_ORDER_INDEXES: Vec = vec![0, 7, 2, 3, 8, 1, 6, 5]; + + /// [ACTUAL DATA] 八卦 (Ba-Gua) in "Lo-Shu" order, however, mapped to 8 compass directions. + /// When "Lo-Shu" (洛書) order is mapped to 8 compass directions, it is convenient + /// to have a vector which starts with 卦 (Gua) for _"NORTH"_ which is "坎" (Kan). + /// Likewise, we want the second item being 卦 (Gua) for _"NORTH EAST"_ which is "艮" (Gen). + /// For the third item, likewise, for _"EAST"_ or "震" (Zhen). + /// + /// 八卦 (Ba-Gua) in "Lo-Shu" order mapped to 8 directions (starting NORTH): + /// + /// [0] 坎 (Kan) + /// [1] 艮 (Gen) + /// [2] 震 (Zhen) + /// [3] 巽 (Xun) + /// [4] 離 (Li) + /// [5] 坤 (Kun) + /// [6] 兌 (Dui) + /// [7] 乾 (Qian) + pub static ref BAGUA_LO_SHU_COMPASS_ORDER: Vec = make_sort( + BAGUA_LO_SHU_COMPASS_ORDER_INDEXES.to_vec() // order + )( + BAGUA_LO_SHU_ORDER_WITH_CENTER.to_vec() // data source ); } -/// A getter for `BAGUA_START_NORTH`. +/// A getter for `BAGUA_LO_SHU_COMPASS_ORDER`. /// /// Example: /// ```rust -/// use mikaboshi::bagua::{get_bagua_start_north, Bagua}; +/// use mikaboshi::bagua::{get_gua_compass_order, Gua}; /// use wasm_bindgen::prelude::*; /// /// #[wasm_bindgen] /// pub fn xx(index: usize) -> JsValue { -/// let bagua: Option<&Bagua> = get_bagua_start_north(index); -/// JsValue::from_serde(&bagua).unwrap() +/// let gua: Option<&Gua> = get_gua_compass_order(index); +/// JsValue::from_serde(&gua).unwrap() /// } /// ``` -pub fn get_bagua_start_north(index: usize) -> Option<&'static Bagua> { - match BAGUA_START_NORTH.get(index) { - Some(bagua) => Some(bagua), +pub fn get_gua_compass_order(index: usize) -> Option<&'static Gua> { + match BAGUA_LO_SHU_COMPASS_ORDER.get(index) { + Some(gua) => Some(gua), None => None, } } @@ -153,11 +242,11 @@ mod tests { use super::*; #[test] - fn test_constant_bagua() { - assert_eq!(BAGUA[0].num, 1); + fn test_constant_bagua_list_full() { + assert_eq!(BAGUA_LO_SHU_ORDER_WITH_CENTER[0].jiuxing_num, 1); } - // TODO: BAGUA_START_NORTH_INDEXES - // TODO: BAGUA_START_NORTH - // TODO: get_get_bagua_start_north + // TODO: BAGUA_LO_SHU_COMPASS_ORDER_INDEXES + // TODO: BAGUA_LO_SHU_COMPASS_ORDER + // TODO: gua_for_start_north } diff --git a/src/compass.rs b/src/compass.rs index b97f7e1..5b2a208 100644 --- a/src/compass.rs +++ b/src/compass.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use crate::bagua::{Bagua, BAGUA}; +use crate::bagua::{Gua, BAGUA_LO_SHU_ORDER_WITH_CENTER}; use crate::ganzhi::{ Branch, Stem, @@ -18,7 +18,7 @@ use crate::ganzhi::{ /// 二十四山向 (Er-Shi-Si Shan-Xiang) can be /// either 卦 (Gua), 干 (Gan), or 支 (Zhi). pub enum TwentyFourType<'a> { - Bagua(&'a Bagua), + Gua(&'a Gua), Stem(&'a Stem), Branch(&'a Branch), } @@ -287,7 +287,7 @@ pub const TWENTYFOUR_ORDER_START_NORTH: [(usize, usize); 24] = [ /// pub fn xx(index: usize) -> JsValue { /// let t_type: TwentyFourType = get_twentyfour_data_from_index(index); /// match t_type { -/// TwentyFourType::Bagua(bagua) => JsValue::from_serde(bagua).unwrap(), +/// TwentyFourType::Gua(gua) => JsValue::from_serde(gua).unwrap(), /// TwentyFourType::Stem(stem) => JsValue::from_serde(stem).unwrap(), /// TwentyFourType::Branch(branch) => JsValue::from_serde(branch).unwrap(), /// } @@ -296,7 +296,7 @@ pub const TWENTYFOUR_ORDER_START_NORTH: [(usize, usize); 24] = [ pub fn get_twentyfour_data_from_index(index: usize) -> TwentyFourType<'static> { let (t_type, t_index) = TWENTYFOUR_ORDER_START_NORTH[index]; match t_type { - 0 => TwentyFourType::Bagua(&BAGUA[t_index]), + 0 => TwentyFourType::Gua(&BAGUA_LO_SHU_ORDER_WITH_CENTER[t_index]), 1 => TwentyFourType::Stem(&STEMS[t_index]), 2 => TwentyFourType::Branch(&BRANCHES[t_index]), _ => panic!("Unknown type: {}", t_type), @@ -397,7 +397,7 @@ pub fn get_twentyfour_index_from_direction(direction: &str, sector: usize) -> us /// pub fn xx(direction: &str, sector: usize) -> JsValue { /// let t_type: TwentyFourType = get_twentyfour_data_from_direction(direction, sector); /// match t_type { -/// TwentyFourType::Bagua(bagua) => JsValue::from_serde(bagua).unwrap(), +/// TwentyFourType::Gua(gua) => JsValue::from_serde(gua).unwrap(), /// TwentyFourType::Stem(stem) => JsValue::from_serde(stem).unwrap(), /// TwentyFourType::Branch(branch) => JsValue::from_serde(branch).unwrap(), /// } diff --git a/src/jiuxing.rs b/src/jiuxing.rs index b2d4c59..739e0e5 100644 --- a/src/jiuxing.rs +++ b/src/jiuxing.rs @@ -1,54 +1,50 @@ -//! At the beginning, the law governing the universe was simple. -//! Yet, as man acquired the faculty of thought, was it no longer so. -//! It was not the universe which changed, but was about how man began -//! to see the universe differently. Thought, after all, is nothing -//! but reflections of the outer world. In another word, the outer -//! world we perceive could only be understood via patterns -//! that are innate to man's thought. Just like "Malkuth" in _Kabbalha_ -//! is about both the earthly kingdom and the man himself, -//! as ancient Chinese attempted describing patterns in the universe, -//! they introduced another artificial element "metal" -//! (or "earth" when it is deployed in actual reality). -//! For the ancient Chinese, the former is called -//! 先天八卦 ("the Primordial Heaven"), and the latter, -//! 後天八卦 ("the Manifested Heaven"). -//! To study the patterns peculiar to each universe, a conventional -//! board with 8 directions and 1 in the center has been in use, -//! where "8 Gua" (八卦) are assigned for slots on the board. -//! However, for many 風水 (Feng-Shui) systems, we are normally -//! dealing with the latter, or 後天八卦 ("the Manifested Heaven"). +//! 九星 (Jiu-Xing) means "9 stars" in Chinese. +//! In 風水 (Feng-Shui), 9 boxes are drawn to represent +//! the spatial condition of the place in concern. +//! The box in the middle represents where you are, +//! and 8 boxes which surrounding the middle represent +//! 8 compass directions. For these 9 boxes, plotted +//! special symbols, each of which is called, a "Star" (星). +//! When we say 九星 (Jiu-Xing) in Chinese, "Jiu" means "9", +//! and "Xing" means a "Star". While 九星 (Jiu-Xing) +//! has fixed positions (associated with 洛書 (Lo-Shu)), +//! they change positions over time, and this movement +//! is called 飞泊 (Fei-Po) or "flying" because of how it +//! appears to our eyes when they move. //! -//! For 後天八卦 ("the Manifested Heaven") has a specific name -//! in 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui), and is called -//! 地盤 (Di-Pan). However, there are 3 more boards in -//! 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui) -//! in addition to 地盤 (Di-Pan), namely: +//! As explained in 八卦 (Ba-Gua) (see: `src/bagua.rs`), +//! there are 2 worldly systems concerned, namely, +//! 先天八卦 (or "the Primordial Heaven") and +//! 後天八卦 (or "the Manifested Heaven"), and we deal +//! with the latter system when we talk about 風水 (Feng-Shui). //! -//! (1) 運盤 (Un-Pan) (or 天盤 (Tien-Pan)) -//! (2) 山星 (Shan-Xing) -//! (3) 向星 (Xiang-Xing) +//! In 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui), there is +//! a special name given to the latter system, and is called, +//! 地盤 (Di-Pan). "Di" means "earth", and "Pan" means "board". +//! So, it is basically a board which is drawn at the bottom +//! of any Feng-Shui charts. On 地盤 (Di-Pan), 九星 (Jiu-Xing) +//! are plotted for which the order is fundamentally that of +//! 洛書 (Lo-Shu) order in 八卦 (Ba-Gua). However, they move +//! (or "fly") over 地盤 (Di-Pan) as time goes. +//! In 玄空飞星風水 (Xuan-Kong Fei-Xing Feng-Shui), there are +//! 3 other boards that are drawn on top of 地盤 (Di-Pan), namely: +//! +//! - 運盤 (Un-Pan) or 天盤 (Tien-Pan) +//! - 山星 (Shan-Xing) +//! - 向星 (Xiang-Xing) //! -//! In practice, for all the above 3 boards, 九星 (Jiu-Xing) -//! or "the Nine Stars" are assigned. While "8 Gua" (八卦) -//! has fixed positions, 九星 (Jiu-Xing) changes -//! over time for spatial constraints given. -//! When their positions change, the movement is called -//! 飞泊 (Fei-Po) or "flying" because of how it appears -//! to our eyes when they move. -//! -//! For the first board 運盤 (Un-Pan), positions of 九星 (Jiu-Xing) -//! are determined by building's construction year, -//! and calculated based on 三元九運 (Sang-Yuan Jiu-Yun) +//! For 運盤 (Un-Pan), positions of 九星 (Jiu-Xing) are determined +//! by construction year for the building in concern which is +//! calculated based on 三元九運 (Sang-Yuan Jiu-Yun), //! or "9 Yearly Cycles". We could say that 運盤 (Un-Pan) -//! essentially describes of the temporal aspect of the building -//! For 山星 (Shan-Xing) and 向星 (Xiang-Xing) are determined -//! by spatial aspects of the building, though, temporal aspects -//! are also associated indirectly in calculations. +//! essentially describes the temporal aspect. +//! 山星 (Shan-Xing) and 向星 (Xiang-Xing) are determined +//! by spatial aspects of the building (however, in actual +//! calculations, some temporal aspects comes in). //! -//! When 運盤 (Un-Pan), 山星 (Shan-Xing), and 向星 (Xiang-Xing) -//! are added to 地盤 (Di-Pan) at the bottom, it is called -//! 下卦図 (Xia-Gua-Tu), or simply referred as -//! 飞星図 (Fei-Xing-Tu; "the Flying Star Chart"). +//! When these 3 extra boards are placed on top of 地盤 (Di-Pan), +//! the whole thing is called, 下卦図 (Xia-Gua-Tu), or simply +//! referred as 飞星図 (Fei-Xing-Tu), or "The Flying Star Chart". //! //! Jiu-Xing (九星): //! diff --git a/src/solar_terms.rs b/src/solar_terms.rs index 8806ee1..2ca2bf9 100644 --- a/src/solar_terms.rs +++ b/src/solar_terms.rs @@ -1,5 +1,6 @@ -//! A module for "二十四节气" (Er-Shi-Si Jie-Qi). -//! Or, for calculating "立春" (Li-Chun). +//! A module for 二十四节气 (Er-Shi-Si Jie-Qi). +//! Or, for calculating 立春 (Li-Chun). + use chrono::Datelike; use chrono::naive::NaiveDate; use serde::{Deserialize, Serialize};