zoukankan      html  css  js  c++  java
  • 数学图形之伞形

    前几天一直在下雨,今天终于晴天了,用算法生成个伞的图形庆祝下。

    伞可以看做是一个圆弧面,通常有8个或6个伞骨。那就先创建个8分的圆弧面看看。

    脚本代码:

    vertices = dimension1:8 dimension2:16
    
    u = from 0 to (2*PI) dimension1
    v = from (PI*0.25) to (PI*0.5) dimension2
    
    x = cos(v)*sin(u)
    y = sin(v)
    z = cos(v)*cos(u)
    
    a = 10.0
    
    x = a*x
    y = a*y
    z = a*z

    生成图形如下:

    一顶简单的伞就生成出来了,但实际中的伞要复杂一些,OK继续优化,下一步使用余弦曲线来凸现伞骨:

    vertices = dimension1:256 dimension2:16
    
    u = from 0 to (2*PI) dimension1
    v = from (PI*0.2) to (PI*0.5) dimension2
    
    s = 1.0 - 0.12*abs(cos(u*4))
    
    x = cos(v)*sin(u)*s
    y = sin(v)
    z = cos(v)*cos(u)*s
    
    a = 10.0
    
    x = a*x
    y = a*y
    z = a*z

    生成图形如下:

    相关软件参见:数学图形可视化工具,使用自己定义语法的脚本代码生成数学图形.该软件免费开源.QQ交流群: 367752815

  • 相关阅读:
    POJ 2154
    POJ 1286
    Polycarp's problems
    Greedy Change
    Goods transportation
    Ugly Problem
    Happy Matt Friends
    Dense Subsequence
    Ray Tracing
    Batch Sort
  • 原文地址:https://www.cnblogs.com/WhyEngine/p/4068839.html
Copyright © 2011-2022 走看看