欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

echarts實(shí)現(xiàn)晶體球面投影的實(shí)例教程

 更新時(shí)間:2020年10月10日 09:58:11   作者:錦繡兮前程  
這篇文章主要給大家介紹了關(guān)于echarts實(shí)現(xiàn)晶體球面投影的相關(guān)資料,文中介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

因?yàn)楣腆w物理書上的球面投影圖太難看,就自學(xué) javascipt 用 echarts 做了個(gè)可交互的,效果如下:

上面為立方晶系主要晶面(晶向)的球面投影,具體計(jì)算代碼如下:

import math
import numpy as np

def c_scale(A):
 A = np.array(A)
 n_dim = A.shape[1]; n_size = A.shape[0]
 scale2 = np.zeros(n_size)
 for j in range(n_dim):
  for i in range(n_size):
   scale2[i] += A[i,j]**2
 scale = scale2 ** 0.5
 return scale

def normalize(A): # 二維數(shù)組歸一化
 A = np.array(A)
 scale = c_scale(A)
 A = np.divide(A.T,scale).T
 return A
 
def cal_point_dict(input_str_list):
 points = []; points_dicts = []
 for input_str in input_str_list:
  input_str=input_str.replace('[',''); input_str=input_str.replace(']','')
  try:
   data = input_str.split(' ')
   point = [] # 求解投影點(diǎn)
   for j in range(len(data)):
    point.append(int(data[j]))
   points.append(point)
  except:
   data = input_str.split(',')
   point = [] # 求解投影點(diǎn)
   for j in range(len(data)):
    point.append(int(data[j]))
   points.append(point)
  points_p = normalize(points)
 for i in range(len(points_p)):
  points_dict={}
  points_dict['name']=input_str_list[i]
  points_dict['value']=points_p[i].tolist()
  points_dicts.append(points_dict)
 return points_dicts

# 各晶面指數(shù)
input_str_list = ['[0 0 1]','[1 0 0]','[0 1 0]','[0 0 -1]','[-1 0 0]','[0 -1 0]',
     '[1 0 1]','[0 1 1]','[1 1 0]','[-1 0 -1]','[0 -1 -1]','[-1 -1 0]',
     '[1 0 -1]','[0 1 -1]','[1 -1 0]','[-1 0 1]','[0 -1 1]','[-1 1 0]',
     '[1 1 1]','[-1 1 1]','[1 -1 1]','[1 1 -1]',
     '[-1 -1 -1]','[1 -1 -1]','[-1 1 -1]','[-1 -1 1]']
points_dicts = cal_point_dict(input_str_list)
points_dicts # 將該數(shù)據(jù)復(fù)制到 球坐標(biāo).html 下

繪圖 html 源碼:

<!DOCTYPE html>
<html style="height: 100%">
 <head>
  <meta charset="utf-8">
 </head>
 <body style="height: 100%; margin: 0">
  <div id="container" style="height: 100%"></div>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-gl/dist/echarts-gl.min.js"></script>
  <script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;

//var data = [{name:'[1 0 0]',value:[1,0,0]},{name:'[0 1 1]',value:[0,1,1]}];
var data1 = 
[{'name': '[0 0 1]', 'value': [0.0, 0.0, 1.0]},
 {'name': '[1 0 0]', 'value': [1.0, 0.0, 0.0]},
 {'name': '[0 1 0]', 'value': [0.0, 1.0, 0.0]},
 {'name': '[0 0 -1]', 'value': [0.0, 0.0, -1.0]},
 {'name': '[-1 0 0]', 'value': [-1.0, 0.0, 0.0]},
 {'name': '[0 -1 0]', 'value': [0.0, -1.0, 0.0]},
 {'name': '[1 0 1]', 'value': [0.7071067811865475, 0.0, 0.7071067811865475]},
 {'name': '[0 1 1]', 'value': [0.0, 0.7071067811865475, 0.7071067811865475]},
 {'name': '[1 1 0]', 'value': [0.7071067811865475, 0.7071067811865475, 0.0]},
 {'name': '[-1 0 -1]',
 'value': [-0.7071067811865475, 0.0, -0.7071067811865475]},
 {'name': '[0 -1 -1]',
 'value': [0.0, -0.7071067811865475, -0.7071067811865475]},
 {'name': '[-1 -1 0]',
 'value': [-0.7071067811865475, -0.7071067811865475, 0.0]},
 {'name': '[1 0 -1]', 'value': [0.7071067811865475, 0.0, -0.7071067811865475]},
 {'name': '[0 1 -1]', 'value': [0.0, 0.7071067811865475, -0.7071067811865475]},
 {'name': '[1 -1 0]', 'value': [0.7071067811865475, -0.7071067811865475, 0.0]},
 {'name': '[-1 0 1]', 'value': [-0.7071067811865475, 0.0, 0.7071067811865475]},
 {'name': '[0 -1 1]', 'value': [0.0, -0.7071067811865475, 0.7071067811865475]},
 {'name': '[-1 1 0]', 'value': [-0.7071067811865475, 0.7071067811865475, 0.0]},
 {'name': '[1 1 1]',
 'value': [0.5773502691896258, 0.5773502691896258, 0.5773502691896258]},
 {'name': '[-1 1 1]',
 'value': [-0.5773502691896258, 0.5773502691896258, 0.5773502691896258]},
 {'name': '[1 -1 1]',
 'value': [0.5773502691896258, -0.5773502691896258, 0.5773502691896258]},
 {'name': '[1 1 -1]',
 'value': [0.5773502691896258, 0.5773502691896258, -0.5773502691896258]},
 {'name': '[-1 -1 -1]',
 'value': [-0.5773502691896258, -0.5773502691896258, -0.5773502691896258]},
 {'name': '[1 -1 -1]',
 'value': [0.5773502691896258, -0.5773502691896258, -0.5773502691896258]},
 {'name': '[-1 1 -1]',
 'value': [-0.5773502691896258, 0.5773502691896258, -0.5773502691896258]},
 {'name': '[-1 -1 1]',
 'value': [-0.5773502691896258, -0.5773502691896258, 0.5773502691896258]}]
 ;


var radius = 1;

option = {
 tooltip: {},
 xAxis3D: {},
 yAxis3D: {},
 zAxis3D: {},
 grid3D: {},
 animation: true,
 series: [{
  name: '參考球',
  type: 'surface',
  parametric: true,
  // shading: 'albedo',
  wireframe: {
   show: true
  },
  shading: 'color',
  itemStyle: {
   color: [1, 1, 1, 1],
   opacity: 0.8
  },

  parametricEquation: {
   u: {
    min: -Math.PI,
    max: Math.PI,
    step: Math.PI / 20
   },
   v: {
    min: 0,
    max: Math.PI,
    step: Math.PI / 20
   },
   x: function (u, v) {
    return radius * Math.sin(v) * Math.sin(u);
   },
   y: function (u, v) {
    return radius * Math.sin(v) * Math.cos(u);
   },
   z: function (u, v) {
    return radius * Math.cos(v);
   }
  }
 },
 {
  name: '球面投影點(diǎn)',
  type: 'scatter3D',
  blendMode: 'darken',
  showEffectOn: 'render',
  zlevel: 2,
  symbol : 'circle',
  label: {
   show: true,
   position: 'top',
   formatter: ''},
  symbolSize: 10,
  data: data1
 }
 ]
};;
if (option && typeof option === "object") {
 myChart.setOption(option, true);
}
  </script>
 </body>
</html>

然而這樣畫出的圖形還不能實(shí)現(xiàn) 3D 空間中的遮擋關(guān)系,要進(jìn)一步實(shí)現(xiàn)可能還要借助 echarts 的地理坐標(biāo)功能。

總結(jié)

到此這篇關(guān)于echarts實(shí)現(xiàn)晶體球面投影的文章就介紹到這了,更多相關(guān)echarts晶體球面投影內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論