首页 > 其他分享 >CatLikeCoding Basic No.3

CatLikeCoding Basic No.3

时间:2023-01-24 16:45:01浏览次数:46  
标签:float CatLikeCoding Vector3 Sin No.3 Basic static PI public

因为后面的圆和环就是跑数学公式了所以偷懒了orz

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.Mathf;

public static class FunctionLibrary 
{//delegate是第一次用到,相当于函数指针,这里是指可以搭载满足输入为3个参数、返回值为Vector3的函数,funcitons就是一个function的数组,每一个元素都是一个满足条件的Function
    public delegate Vector3 Function(float x, float z, float t);
    static Function[] functions = { Wave, MultiWave, Ripple };
    public enum functionname { Wave,MultiWave, Ripple};
    public static Function GetFunction(functionname name)
    {
        return functions[(int)name];//注意这里要变下int类型,虽然是枚举
    }
    public static Vector3 Wave(float u, float v, float t)
    {
        Vector3 p;
        p.x = u;
        p.y = Sin(PI * (u + v + t));
        p.z = v;
        return p;
    }
    public static Vector3 MultiWave(float u, float v, float t)
    {
        Vector3 p;
        p.x = u;
        p.y = Sin(PI * (u + 0.5f*t));
        p.y += Sin(2f * PI * (v + t)) * (1f / 2f);
        p.y += Sin(PI * (u + v + 0.25f * t));
        p.y *= (1f / 2.5f);
        p.z = v;
        return p;
        
    }
    public static Vector3 Ripple(float u, float v, float t)
    {
        float d = Sqrt(u * u + v * v);
        Vector3 p;
        p.x = u;
        p.y = Sin(PI * (4f * d - t));
        p.y /= 1f + 10f * d;
        p.z = v;
        return p;
    }
}

 

 

 

 

 

 

标签:float,CatLikeCoding,Vector3,Sin,No.3,Basic,static,PI,public
From: https://www.cnblogs.com/lofu/p/17066156.html

相关文章

  • Javascript Basic
    Javascriptisa dynamicallytyped, weaklytypedand interpreted high-levelprogramminglanguage.InterestingJavaScriptFeaturesWe'llgoovertheseinmor......
  • Basic Linux User Guide
    NormalUbuntuUserGuide!ConceptsEverythingisfile.Opensource.Usefulknowledge.desktopfile-shorticonA.desktopfileissimplyashortcutthat......
  • CatLikeCoding Basic No.2
        graph.csusingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassgraph:MonoBehaviour{[SerializeField]......
  • CatLikeCoding Basic No.1
      usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingSystem;publicclassclock:MonoBehaviour{constfloathour......
  • 【推荐系统】矩阵分解MF利用BASIC-SVD分解
    如果需要完整代码可以关注下方公众号,后台回复“代码”即可获取,阿光期待着您的光临~文章目录​​1.矩阵分解算法的求解​​​​2.优化函数的修改​​​​3.BASIC-SVD编程实现......
  • 【Basic Knowledge】Self-Attention Generative Adversarial Networks
    Note  这是一篇将Self-Attention应用到GAN中的paper,Self-Attention模块是卷积模块的补充,能够有助于建模跨图像区域的长范围、多层次依赖关系。文中主要提到4点:在生......
  • dpdk入门实践5--basicfwd和pktgen
    安装pktgen我之前安装的dpdk版本是stable-18.11.2,linux版本为3.10.0-1160.36.2.el7.x86_64,从网站http://git.dpdk.org/apps/pktgen-dpdk/refs/下载尝试多个版本的pktg......
  • Basic Concepts of STM32 (1)
           ......
  • 人大金仓Linux安装启动报错-bash: basic_path: 未找到命令
    linux系统安装人大金仓,莫名报错,报错为找到bash命令basic_path。感觉是脚本那个位置写错,(但是这个包是官网上面的包,照常安装应该不会出现问题)去/opt/Kingbase/ES/V8/data/......
  • nginx: [emerg] "auth_basic" directive is duplicate
    错误信息nginx:[emerg]"auth_basic"directiveisduplicateinphpmyadmin.conf:14nginx:configurationfilenginx.conftestfailed根原因phpmyadmin开启了ss......