• [Canvas画图] 藏图阁(16) 人体穴位


    本节目标:

    趁着今天是愚人节。阿伟决定来重温一下学医的那段日子。

    有那么一段时间,

    阿伟对武侠小说和医学同一时候产生了浓厚的兴趣,当时最想学的就是葵花点穴手,

    一阳指之类的点穴功夫。轻轻一点。就能把别人定在那里当雕像观看。

    那时做梦

    都想打通浑身经脉,练成绝顶武功。可惜后来发现那些都仅仅是小说。

    好了。故事就说这么多,还是来画一绘图吧。

















    这次的图很的难看,阿伟自己都看不下去。这时阿伟想起了上学时学过鲁迅写的一篇

    叫做《藤野先生》的文章,写他自己去岛国留学去学医时,遇到的唯一的一个不鄙视当时大国

    子民的教授,那位教授就对鲁迅说。“解剖学不是美术”。果然,涉及到人体的图。就不能当美术

    来看了。


    这里贴一下人体的400多个穴位,坐标都当不得真,由于今天是愚人节。阿伟再次强调一遍。

    其实阿伟实在没这个能力求得穴位准确坐标。否则点穴神功早就练成了。


    [2, 150, 20, '睛明穴'],
    [2, 151, 20, '攒竹穴'],
    [2, 155, 19, '眉冲穴'],
    [3, 155, 19, '曲差穴'],
    [3, 154, 18, '五处穴'],
    [0, 0, 0, '承光穴'],
    [2, 158, 2, '通天穴'],
    [2, 156, 0, '络却穴'],
    [2, 144, 0, '玉枕穴'],
    [2, 140, 0, '天柱穴'],
    [5, 135, 0, '大杼穴'],
    [5, 133, 0, '风门穴'],
    [5, 131, 0, '肺俞穴'],
    [5, 129, 0, '厥阴俞穴'],
    [5, 127, 0, '心俞穴'],
    [5, 125, 0, '督俞穴'],
    [5, 123, 0, '膈俞穴'],
    [5, 119, 0, '肝俞穴'],
    [5, 117, 0, '胆俞穴'],
    [5, 115, 0, '脾俞穴'],
    [5, 113, 0, '胃俞穴'],
    [5, 111, 0, '三焦俞穴'],
    [5, 109, 0, '肾俞穴'],
    [5, 107, 0, '气海俞穴'],
    [5, 105, 0, '大肠俞穴'],
    [5, 103, 0, '关元俞穴'],
    [5, 101, 0, '小肠俞穴'],
    [5, 99, 0, '膀胱俞穴'],
    [5, 97, 0, '中膂俞穴'],
    [5, 95, 0, '白环俞穴'],
    [2, 103, 0, '上髎穴'],
    [2, 101, 0, '次髎穴'],
    [2, 99, 0, '中髎穴'],
    [2, 97, 0, '下髎穴'],
    [2, 91, 0, '会阳穴'],
    [5, 80, 0, '承扶穴'],
    [5, 60, 0, '殷门穴'],
    [15, 42, 0, '浮郄穴'],
    [15, 40, 0, '委阳穴'],
    [10, 40, 0, '委中穴'],
    [10, 130, 0, '附分穴'],
    [10, 128, 0, '魄户穴'],
    [10, 126, 0, '膏肓穴'],
    [10, 124, 0, '神堂穴'],
    [10, 122, 0, '譩譆穴'],
    [10, 120, 0, '膈关穴'],
    [10, 115, 0, '魂门穴'],
    [10, 113, 0, '阳纲穴'],
    [10, 111, 0, '意舍穴'],
    [10, 109, 0, '胃仓穴'],
    [10, 107, 0, '肓门穴'],
    [10, 105, 0, '志室穴'],
    [10, 97, 0, '胞肓穴'],
    [10, 93, 0, '秩边穴'],
    [10, 40, 0, '合阳穴'],
    [10, 36, 0, '承筋穴'],
    [10, 32, 0, '承山穴'],
    [10, 30, 0, '飞扬穴'],
    [10, 15, 0, '跗阳穴'],
    [10, 8, 0, '昆仑穴'],
    [10, 6, 0, '仆參穴'],
    [10, 6, 10, '申脉穴'],
    [10, 3, 10, '金门穴'],
    [10, 3, 12, '京骨穴'],
    [10, 3, 14, '束骨穴'],
    [10, 3, 16, '足通骨穴'],
    [10, 3, 20, '至阴穴'],
    [14, 2, 30, '大敦穴'],
    [14, 2, 28, '行间穴'],
    [14, 3, 25, '太冲穴'],
    [14, 6, 20, '中封穴'],
    [14, 20, 20, '蠡沟穴'],
    [14, 28, 20, '中都穴'],
    [0, 0, 0, '膝关穴'],
    [0, 0, 0, '曲泉穴'],
    [14, 52, 10, '阴包穴'],
    [12, 84, 10, '足五里穴'],
    [12, 86, 10, '阴廉穴'],
    [12, 88, 10, '急脉穴'],
    [18, 104, 30, '章门穴'],
    [14, 114, 30, '期门穴'],
    [8, 150, 20, '瞳子髎穴'],
    [9, 147, 12, '听会穴'],
    [9, 150, 12, '上关穴'],
    [0, 0, 0, '颔厌穴'],
    [0, 0, 0, '悬颅穴'],
    [0, 0, 0, '悬厘穴'],
    [0, 0, 0, '曲鬓穴'],
    [10, 152, 0, '率谷穴'],
    [8, 150, 0, '天冲穴'],
    [7, 146, 0, '浮白穴'],
    [6, 145, 0, '头窍阴穴'],
    [8, 142, 0, '完骨穴'],
    [6, 158, 18, '本神穴'],
    [5, 152, 20, '阳白穴'],
    [4, 155, 19, '头临泣穴'],
    [4, 156, 19, '目窗穴'],
    [0, 0, 0, '正营穴'],
    [0, 0, 0, '承灵穴'],
    [5, 147, 0, '脑空穴'],
    [5, 143, 0, '风池穴'],
    [12, 5, 140, '肩井穴'],
    [0, 0, 0, '渊腋穴'],
    [0, 0, 0, '辄筋穴'],
    [0, 0, 0, '日月穴'],
    [0, 0, 0, '京门穴'],
    [0, 0, 0, '带脉穴'],
    [0, 0, 0, '五枢穴'],
    [0, 0, 0, '维道穴'],
    [0, 0, 0, '居髎穴'],
    [0, 0, 0, '环跳穴'],
    [0, 0, 0, '风市穴'],
    [0, 0, 0, '中渎穴'],
    [0, 0, 0, '膝阳关穴'],
    [0, 0, 0, '阳陵泉穴'],
    [0, 0, 0, '阳交穴'],
    [0, 0, 0, '外丘穴'],
    [0, 0, 0, '光明穴'],
    [0, 0, 0, '阳辅穴'],
    [0, 0, 0, '悬钟穴'],
    [0, 0, 0, '丘墟穴'],
    [0, 0, 0, '足临泣穴'],
    [0, 0, 0, '地五会穴'],
    [0, 0, 0, '侠溪穴'],
    [0, 0, 0, '足窍阴穴'],
    [20, 130, 15, '极泉穴'],
    [24, 125, 15, '青灵穴'],
    [24, 120, 15, '少海穴'],
    [24, 98, 15, '灵道穴'],
    [24, 97, 15, '通里穴'],
    [24, 96, 15, '阴郄穴'],
    [24, 95, 15, '神门穴'],
    [24, 85, 15, '少府穴'],
    [23, 71, 15, '少冲穴'],
    [12, 2, 30, '隐白穴'],
    [12, 2, 28, '大都穴'],
    [12, 2, 26, '太白穴'],
    [12, 3, 24, '公孙穴'],
    [12, 8, 20, '商丘穴'],
    [12, 15, 20, '三阴交穴'],
    [12, 22, 20, '漏谷穴'],
    [12, 30, 20, '地机穴'],
    [12, 36, 20, '阴陵泉穴'],
    [12, 45, 10, '血海穴'],
    [12, 65, 10, '箕门穴'],
    [12, 88, 10, '冲门穴'],
    [12, 91, 10, '府舍穴'],
    [12, 100, 30, '腹结穴'],
    [12, 103, 30, '大横穴'],
    [12, 112, 30, '腹哀穴'],
    [14, 118, 30, '食窦穴'],
    [14, 122, 30, '天溪穴'],
    [14, 125, 30, '胸乡穴'],
    [14, 128, 30, '周荣穴'],
    [0, 0, 0, '大包穴'],
    [0, 0, 0, '商阳穴'],
    [0, 0, 0, '二间穴'],
    [0, 0, 0, '三间穴'],
    [0, 0, 0, '合谷穴'],
    [0, 0, 0, '阳溪穴'],
    [0, 0, 0, '偏历穴'],
    [0, 0, 0, '温溜穴'],
    [0, 0, 0, '下廉穴'],
    [0, 0, 0, '上廉穴'],
    [0, 0, 0, '手三里穴'],
    [0, 0, 0, '曲池穴'],
    [0, 0, 0, '肘髎穴'],
    [0, 0, 0, '手五里穴'],
    [0, 0, 0, '臂臑穴'],
    [0, 0, 0, '肩髃穴'],
    [0, 0, 0, '巨骨穴'],
    [9, 138, 10, '天鼎穴'],
    [9, 140, 10, '扶突穴'],
    [0, 0, 0, '口禾髎穴'],
    [0, 0, 0, '迎香穴'],
    [22, 72, 15, '少泽穴'],
    [22, 78, 15, '前谷穴'],
    [22, 80, 15, '后溪穴'],
    [22, 90, 15, '腕骨穴'],
    [22, 91, 15, '阳谷穴'],
    [22, 92, 15, '养老穴'],
    [22, 100, 15, '支正穴'],
    [22, 110, 15, '小海穴'],
    [18, 126, 0, '肩贞穴'],
    [18, 134, 0, '臑俞穴'],
    [15, 126, 0, '天宗穴'],
    [15, 134, 0, '秉风穴'],
    [13, 131, 0, '曲垣穴'],
    [12, 132, 0, '肩外俞穴'],
    [10, 135, 0, '肩中俞穴'],
    [10, 144, 3, '天窗穴'],
    [10, 142, 10, '天容穴'],
    [0, 0, 0, '颧髎穴'],
    [10, 150, 10, '听宫穴'],
    [13, 132, 30, '中府穴'],
    [12, 134, 30, '云门穴'],
    [28, 125, 15, '天府穴'],
    [28, 122, 15, '侠白穴'],
    [28, 110, 15, '尺泽穴'],
    [28, 100, 15, '孔最穴'],
    [28, 92, 15, '列缺穴'],
    [28, 91, 15, '经渠穴'],
    [28, 90, 15, '太渊穴'],
    [30, 86, 15, '鱼际穴'],
    [30, 80, 15, '少商穴'],
    [5, 147, 20, '承泣穴'],
    [5, 146, 20, '四白穴'],
    [5, 144, 20, '巨髎穴'],
    [5, 142, 20, '地仓穴'],
    [0, 0, 0, '大迎穴'],
    [8, 144, 18, '颊车穴'],
    [0, 0, 0, '下关穴'],
    [8, 158, 19, '头维穴'],
    [9, 138, 15, '人迎穴'],
    [9, 136, 15, '水突穴'],
    [9, 134, 15, '气舍穴'],
    [12, 134, 30, '缺盆穴'],
    [8, 132, 30, '气户穴'],
    [9, 130, 30, '库房穴'],
    [10, 128, 30, '屋翳穴'],
    [10, 126, 30, '膺窗穴'],
    [10, 122, 30, '乳中穴'],
    [10, 119, 30, '乳根穴'],
    [4, 115, 30, '不容穴'],
    [4, 113, 30, '承满穴'],
    [4, 111, 30, '梁门穴'],
    [4, 109, 30, '关门穴'],
    [4, 107, 30, '太乙穴'],
    [4, 105, 30, '滑肉门穴'],
    [4, 103, 30, '天枢穴'],
    [4, 101, 30, '外陵穴'],
    [4, 97, 30, '大巨穴'],
    [4, 95, 30, '水道穴'],
    [4, 93, 30, '归来穴'],
    [4, 91, 30, '气冲穴'],
    [16, 80, 10, '髀关穴'],
    [16, 60, 10, '伏兔穴'],
    [16, 48, 10, '阴市穴'],
    [16, 46, 10, '梁丘穴'],
    [16, 38, 20, '犊鼻穴'],
    [16, 34, 20, '足三里穴'],
    [16, 28, 20, '上巨虚穴'],
    [14, 24, 20, '条口穴'],
    [14, 22, 20, '下巨虚穴'],
    [16, 24, 20, '丰隆穴'],
    [16, 8, 20, '解溪穴'],
    [16, 5, 24, '冲阳穴'],
    [16, 4, 26, '陷谷穴'],
    [16, 3, 28, '内庭穴'],
    [16, 2, 30, '厉兑穴'],
    [18, 120, 30, '天池穴'],
    [26, 125, 15, '天泉穴'],
    [26, 115, 15, '曲泽穴'],
    [26, 102, 15, '郄门穴'],
    [26, 96, 15, '间使穴'],
    [26, 94, 15, '内关穴'],
    [26, 90, 15, '大陵穴'],
    [26, 82, 15, '劳宫穴'],
    [26, 70, 15, '中冲穴'],
    [0, 0, 0, '涌泉穴'],
    [0, 0, 0, '然谷穴'],
    [0, 0, 0, '太溪穴'],
    [0, 0, 0, '大钟穴'],
    [0, 0, 0, '水泉穴'],
    [0, 0, 0, '照海穴'],
    [0, 0, 0, '复溜穴'],
    [0, 0, 0, '交信穴'],
    [0, 0, 0, '筑宾穴'],
    [0, 0, 0, '阴谷穴'],
    [2, 91, 30, '横骨穴'],
    [2, 94, 30, '大赫穴'],
    [2, 97, 30, '气穴'],
    [2, 100, 30, '四满穴'],
    [2, 103, 30, '中注穴'],
    [2, 107, 30, '肓俞穴'],
    [2, 112, 30, '商曲穴'],
    [2, 114, 30, '石关穴'],
    [2, 116, 30, '阴都穴'],
    [2, 119, 30, '腹通谷穴'],
    [2, 121, 30, '幽门穴'],
    [4, 125, 30, '步廊穴'],
    [4, 127, 30, '神封穴'],
    [4, 129, 30, '灵墟穴'],
    [4, 131, 30, '神藏穴'],
    [4, 133, 30, '彧中穴'],
    [4, 135, 30, '俞府穴'],
    [24, 72, 12, '关冲穴'],
    [24, 82, 12, '液门穴'],
    [24, 84, 12, '中渚穴'],
    [24, 90, 12, '阳池穴'],
    [24, 94, 12, '外关穴'],
    [24, 96, 12, '支沟穴'],
    [22, 96, 12, '会宗穴'],
    [24, 98, 12, '三阳络穴'],
    [24, 104, 12, '四渎穴'],
    [24, 110, 12, '天井穴'],
    [24, 113, 12, '清冷渊穴'],
    [24, 123, 12, '消泺穴'],
    [24, 130, 12, '臑会穴'],
    [24, 140, 0, '肩髎穴'],
    [0, 0, 0, '天髎穴'],
    [0, 0, 0, '天牖穴'],
    [0, 0, 0, '翳风穴'],
    [0, 0, 0, '瘛脉穴'],
    [0, 0, 0, '颅息穴'],
    [10, 150, 8, '角孙穴'],
    [0, 0, 0, '耳门穴'],
    [0, 0, 0, '耳和髎穴'],
    [9, 151, 19, '丝竹空穴'],
    [0, 0, 0, '长强穴'],
    [0, 0, 0, '腰俞穴'],
    [0, 0, 0, '腰阳关穴'],
    [0, 0, 0, '命门穴'],
    [0, 0, 0, '悬枢穴'],
    [0, 0, 0, '脊中穴'],
    [0, 0, 0, '中枢穴'],
    [0, 0, 0, '筋缩穴'],
    [0, 0, 0, '至阳穴'],
    [0, 0, 0, '灵台穴'],
    [0, 0, 0, '神道穴'],
    [0, 0, 0, '身柱穴'],
    [0, 0, 0, '陶道穴'],
    [0, 0, 0, '大椎穴'],
    [0, 141, 0, '哑门穴'],
    [0, 142, 0, '风府穴'],
    [0, 0, 0, '脑户穴'],
    [0, 150, 0, '强间穴'],
    [0, 157, 0, '后顶穴'],
    [0, 160, 10, '百会穴'],
    [0, 0, 0, '前顶穴'],
    [0, 0, 0, '囟会穴'],
    [0, 159, 20, '上星穴'],
    [0, 158, 20, '神庭穴'],
    [0, 144, 21, '素髎穴'],
    [0, 143, 20, '鼻通穴'],
    [0, 144,20, '水沟穴'],
    [0, 143, 20, '兑端穴'],
    [0, 0, 0, '龈交穴'],
    [0, 90, 15, '会阴穴'],
    [0, 92, 30, '曲骨穴'],
    [0, 96, 30, '中极穴'],
    [0, 100, 30, '关元穴'],
    [0, 101, 30, '石门穴'],
    [0, 103, 30, '气海穴'],
    [0, 105, 30, '阴交穴'],
    [0, 107, 30, '神阙穴'],
    [0, 109, 30, '水分穴'],
    [0, 111, 30, '下脘穴'],
    [0, 113, 30, '建里穴'],
    [0, 115, 30, '中脘穴'],
    [0, 117, 30, '上脘穴'],
    [0, 119, 30, '巨阙穴'],
    [0, 121, 30, '鸠尾穴'],
    [0, 123, 30, '中庭穴'],
    [0, 125, 30, '膻中穴'],
    [0, 127, 30, '玉堂穴'],
    [0, 129, 30, '紫宫穴'],
    [0, 131, 30, '华盖穴'],
    [0, 133, 30, '璇玑穴'],
    [0, 135, 30, '天突穴'],
    [0, 139, 17, '廉泉穴'],
    [0, 142, 20, '承浆穴'],
    [0, 0, 0, '四神聪穴'],
    [0, 0, 0, '当阳穴'],
    [0, 152, 20, '印堂穴'],
    [8, 152, 20, '鱼腰穴'],
    [0, 146, 20, '人中穴'],
    [8, 152, 18, '太阳穴'],
    [10, 152, 10, '耳尖穴'],
    [0, 0, 0, '球后穴'],
    [2, 148, 20, '上迎香穴'],
    [0, 0, 0, '内迎香穴'],
    [0, 0, 0, '聚泉穴'],
    [0, 0, 0, '海泉穴'],
    [0, 0, 0, '金津穴'],
    [0, 0, 0, '玉液穴'],
    [0, 0, 0, '翳明穴'],
    [0, 0, 0, '颈百劳穴'],
    [0, 0, 0, '子宫穴'],
    [0, 0, 0, '定喘穴'],
    [0, 0, 0, '夹脊穴'],
    [0, 0, 0, '胃脘下俞穴'],
    [0, 0, 0, '痞根穴'],
    [0, 0, 0, '下极俞穴'],
    [0, 0, 0, '腰宜穴'],
    [0, 0, 0, '腰眼穴'],
    [0, 0, 0, '十七椎穴'],
    [0, 0, 0, '腰奇穴'],
    [0, 0, 0, '肘尖穴'],
    [0, 0, 0, '二白穴'],
    [0, 0, 0, '中泉穴'],
    [0, 0, 0, '中魁穴'],
    [0, 0, 0, '大骨空穴'],
    [0, 0, 0, '小骨空穴'],
    [0, 0, 0, '腰痛点穴'],
    [0, 0, 0, '外劳宫穴'],
    [0, 0, 0, '八邪穴'],
    [0, 0, 0, '四缝穴'],
    [0, 0, 0, '十宣穴'],
    [0, 0, 0, '髋骨穴'],
    [0, 0, 0, '鹤顶穴'],
    [0, 0, 0, '百虫窝穴'],
    [0, 0, 0, '内膝眼穴'],
    [0, 0, 0, '膝眼穴'],
    [0, 0, 0, '胆囊穴'],
    [0, 0, 0, '阑尾穴'],
    [0, 0, 0, '内踝尖穴'],
    [0, 0, 0, '外踝尖穴'],
    [0, 0, 0, '八风穴'],
    [0, 0, 0, '独阴穴'],
    [0, 0, 0, '气端穴'],
    [0, 0, 0, '发际穴'],
    [0, 0, 0, '或中穴'],
    [0, 0, 0, '治喘穴'],
    [0, 0, 0, '上仙点穴'],
    [0, 0, 0, '六华灸穴'],
    [0, 0, 0, '治痒穴'],
    [0, 0, 0, '落枕穴'],
    [0, 0, 0, '指间穴'],
    [0, 0, 0, '口内点穴'],
    [0, 0, 0, '胃肠点穴'],
    [0, 0, 0, '百里穴'],
    [0, 0, 0, '里内庭穴'],
    [0, 0, 0, '下痢穴'],
    [0, 0, 0, '第三厉兑穴'],
    


    然后是产生这些图的工具:

    		var r = 20;    
      
            config.setSector(1,1,1,1);      
            //config.graphPaper3D(0, 0, 0, r);    
            config.axis3D(0, 0, 0, 180);  
             
    		plot.setTransform(0, 0);
    		
    		var nX = xGlobal, nY = yGlobal;
            
            //点的坐标阵列  
            //格式为[[px1, py1], [px2, py2], ...]  
            var array = $acupointArray;
    		var arraySet = [], pointArray = [], label = [];
    		
    		var tmp1 = [], tmp2 = [], x, y;
    		
    		var len = array.length;
    		
    		//比例缩放  
    		var scale = r;  
    			
    		for (var i = 0; i < len; i++) {
    			tmp1 = array[i].slice(0, 3);
    			
    			//还没有设置坐标的穴位。略过
    			if (tmp1[0] + tmp1[1] + tmp1[2] <= 0) continue;
    			
    			
    			//三维点投影成二维点
    			tmp1 = shape.point3D(tmp1[0], tmp1[1], tmp1[2]);
    			x = tmp1[0];
    			y = tmp1[1];
    			
    			if (x*scale-nX*600<600 && y*scale-nY*400<400) {
    				arraySet.push(array[i]);
    			}
    		}
    			
    			
            
    
            //点的数量  
            var points = arraySet.length;  
    		
    		var x1, y1, z1, x2, y2,z2, point2D;  
    		
    		for (var i = 0; i < points; i++) {
    			x1 = arraySet[i][0];
    			y1 = arraySet[i][1];
    			z1 = arraySet[i][2];
    			
    			//三维点投影成二维点
    			point2D = shape.point3D(x1, y1, z1);
    			//这里的arraySet[i][3]是穴位的名称。

    pointArray.push([point2D[0]-nX*600/scale, point2D[1]-nY*400/scale, arraySet[i][3]]); } //document.write(pointArray+'<br/>'); if (arraySet.length > 0) { //得到距离阵列 //格式为[[点1序号,点2序号, 距离值], ...] var distanceArray = problemSolve(arraySet); //边的数量 var edges = distanceArray.length; //存放须要连通的边 var linkedArray = []; //连通的边的数量 var links = 0; //每一个顶点相关的边的集合 var edgeOfVertex = []; for (var i = 0; i < points; i++) { //获得顶点相关的边的集合 edgeOfVertex = []; for (var j = 0; j < edges; j++) { if (distanceArray[j][0] == i || distanceArray[j][1] == i) { edgeOfVertex.push(distanceArray[j]); } } //依据起始点寻找最短长度的两条边 edgeOfVertex.sort(function(a, b) { return a[2] - b[2]; }); var choice = 3; if (edgeOfVertex.length > choice) { edgeOfVertex = edgeOfVertex.slice(0, choice); } linkedArray = linkedArray.concat(edgeOfVertex); } //document.write(linkedArray.join(' , ')+'<br/>'); linkedArray = removeDuplicatedPoint(linkedArray); links = linkedArray.length; //document.write(linkedArray.join(' , ')+'<br/>'); var startPoint, endPoint; for (var i = 0; i < links; i++) { startPoint = linkedArray[i][0]; endPoint = linkedArray[i][1]; x1 = pointArray[startPoint][0]; y1 = pointArray[startPoint][1]; x2 = pointArray[endPoint][0]; y2 = pointArray[endPoint][1]; shape.multiLineDraw([[x1,y1], [x2, y2]], 'red', scale); } pointArray = removeDuplicatedPoint(pointArray); len = pointArray.length; var pointArray2 = []; for (var i = 0; i < len; i++) { tmp1 = pointArray[i]; pointArray2.push([tmp1[0], tmp1[1]]); label.push(tmp1[2]); } shape.pointDraw(pointArray2, 'blue', scale, label); } xGlobal = nX; yGlobal = nY; }


    //解决某个特定问题
    function problemSolve(pointArray) {
    	//传入点阵列pointArray
    	//格式为[[px1, py1], [px2, py2], ...]
    
    	//document.write(pointArray.join(' , ')+'<br/>');
    	
    	//对于pointArray中的每一个点,求它与全部其他点的距离
    	//结果放入distanceArray
    	//格式为[[点1序号,点2序号, 距离值]]
    	var distanceArray = [];
    	
    	//点的数量
    	var size = pointArray.length;	
    	
    	//暂时变量
    	var distance = x1 = y1 = z1 = x2 = y2 = z2 = 0;
    	
    	var dimension = pointArray[0].length;
    	
    
    		
    	//计算并压入距离
    	for (var i = 0; i < size; i++) {
    		for (var j = i+1; j < size; j++) {
    			x1 = pointArray[i][0];
    			y1 = pointArray[i][1];			
    			
    			x2 = pointArray[j][0];
    			y2 = pointArray[j][1];
    			
    			if (dimension > 2) {
    				//三维点的处理
    				z1 = pointArray[i][2];
    				z2 = pointArray[j][2];
    				distance = Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2)+Math.pow(z1-z2, 2));
    				
    			}
    			else {
    				distance = Math.sqrt(Math.pow(x1-x2, 2)+Math.pow(y1-y2, 2));
    			}
    			
    			//注意这里已经保证i < j
    			//所以起始点序号必需要小于终点序号
    			//这是为了连接起始点和终点的直线不会反复
    			distanceArray.push([i, j, distance]);
    		}
    	}
    	
    	//对距离阵列排序
    	//排序权重:起始点序号 >  距离 > 终点序号 
    	distanceArray.sort(function(a, b) {
    		if (a[0] == b[0]) {
    			if (Math.abs(a[2] - b[2]) < 0.000001) {
    				return a[1]-b[1];
    			}
    			else {
    				return a[2]-b[2];
    			}
    		
    		}
    		else {
    			return a[0] - b[0];
    		}
    	});
    	
    	//document.write(distanceArray.join(' , ')+'<br/>');
    	
    	return distanceArray;
    }
    
    //去除反复点
    function removeDuplicatedPoint(pointArray) {
    	var array = new Array();
    	var size = pointArray.length;
    	
    	array.push(pointArray[0]);
    	var len = 0;
    	
    	for (var i = 0; i < size; i++) {
    		len = array.length;
    		
    		for (var j = 0; j < len; j++) {
    			if (pointArray[i][0] == array[j][0] &&
    				pointArray[i][1] == array[j][1]) {
    				break;
    			}
    			
    			if (j >= len-1) {
    				array.push(pointArray[i]);
    			}
    		}
    	}
    	return array;
    }
    	


    def tmp():
        fin = open('input.txt');
        fout= open('output.txt', 'a');
    
        acupointArray = [];
        for line in fin.readlines():
            if line[-1] == '
    ':
                line = line[:-1];     
                
            if line == '':
                continue;
            elif line.startswith('#'):
                print(line);
                fout.write(line+'
    ');
            else:
                if (line[-1] != '穴'):
                    line+='穴';
                size = len(acupointArray);
    
                if size == 0:
                    acupointArray.append(line);
                else:
                    for i in range(size):
                        if acupointArray[i] == line:
                            break;
    
                        if i >= size-1:
                            acupointArray.append(line);
        size = len(acupointArray);
        for i in range(size):
            fout.write('[0, 0, 0, '{0}'],
    '.format(acupointArray[i]));
    
        return;


    本节到此结束

  • 相关阅读:
    函数(五)——装饰器,递归调用,匿名函数
    函数(四)——装饰器
    函数(三)
    函数(二)
    函数(一)
    python基础(九)
    python基础(八)
    python基础(七)
    javaweb开发 idea ssm开发(二)
    PHP计算两个经纬度地点之间的距离
  • 原文地址:https://www.cnblogs.com/yutingliuyl/p/7150934.html
Copyright © 2020-2023  润新知