Cube 3D
Transcript: Imports System.Collections Imports System.Collections.Generic Imports System.Data Imports System.Drawing Imports System.Diagnostics Imports System.Windows.Forms Imports System.Linq Imports System.Xml.Linq Imports System.Threading.Tasks Imports System.Runtime.CompilerServices Public Class OpenSimplexNoise Private Const STRETCH_2D As Double = -0.211324865405187 '(1/Math.sqrt(2+1)-1)/2; Private Const STRETCH_3D As Double = -1.0 / 6.0 '(1/Math.sqrt(3+1)-1)/3; Private Const STRETCH_4D As Double = -0.138196601125011 '(1/Math.sqrt(4+1)-1)/4; Private Const SQUISH_2D As Double = 0.366025403784439 '(Math.sqrt(2+1)-1)/2; Private Const SQUISH_3D As Double = 1.0 / 3.0 '(Math.sqrt(3+1)-1)/3; Private Const SQUISH_4D As Double = 0.309016994374947 '(Math.sqrt(4+1)-1)/4; Private Const NORM_2D As Double = 1.0 / 47.0 Private Const NORM_3D As Double = 1.0 / 103.0 Private Const NORM_4D As Double = 1.0 / 30.0 Private perm As Byte() Private perm2D As Byte() Private perm3D As Byte() Private perm4D As Byte() Private Shared gradients4D As Double() = {3, 1, 1, 1, 1, 3, _ 1, 1, 1, 1, 3, 1, _ 1, 1, 1, 3, -3, 1, _ 1, 1, -1, 3, 1, 1, _ -1, 1, 3, 1, -1, 1, _ 1, 3, 3, -1, 1, 1, _ 1, -3, 1, 1, 1, -1, _ 3, 1, 1, -1, 1, 3, _ -3, -1, 1, 1, -1, -3, _ 1, 1, -1, -1, 3, 1, _ -1, -1, 1, 3, 3, 1, _ -1, 1, 1, 3, -1, 1, _ 1, 1, -3, 1, 1, 1, _ -1, 3, -3, 1, -1, 1, _ -1, 3, -1, 1, -1, 1, _ -3, 1, -1, 1, -1, 3, _ 3, -1, -1, 1, 1, -3, _ -1, 1, 1, -1, -3, 1, _ 1, -1, -1, 3, -3, -1, _ -1, 1, -1, -3, -1, 1, _ -1, -1, -3, 1, -1, -1, _ -1, 3, 3, 1, 1, -1, _ 1, 3, 1, -1, 1, 1, _ 3, -1, 1, 1, 1, -3, _ -3, 1, 1, -1, -1, 3, _ 1, -1, -1, 1, 3, -1, _ -1, 1, 1, -3, 3, -1, _ 1, -1, 1, -3, 1, -1, _ 1, -1, 3, -1, 1, -1, _ 1, -3, -3, -1, 1, -1, _ -1, -3, 1, -1, -1, -1, _ 3, -1, -1, -1, 1, -3, _ 3, 1, -1, -1, 1, 3, _ -1, -1, 1, 1, -3, -1, _ 1, 1, -1, -3, -3, 1, _ -1, -1, -1, 3, -1, -1, _ -1, 1, -3, -1, -1, 1, _ -1, -3, 3, -1, -1, -1, _ 1, -3, -1, -1, 1, -1, _ -3, -1, 1, -1, -1, -3, _ -3, -1, -1, -1, -1, -3, _ -1, -1, -1, -1, -3, -1, _ -1, -1, -1, -3} Private Shared lookup4D As Contribution4() Shared Sub New() Dim base4D = New Integer()() {New Integer() {0, 0, 0, 0, 0, 1, _ 1, 0, 0, 0, 1, 0, _ 1, 0, 0, 1, 0, 0, _ 1, 0, 1, 0, 0, 0, _ 1}, New Integer() {3, 1, 1, 1, 0, 3, _ 1, 1, 0, 1, 3, 1, _ 0, 1, 1, 3, 0, 1, _ 1, 1, 4, 1, 1, 1, _ 1}, New Integer() {1, 1, 0, 0, 0, 1, _ 0, 1, 0, 0, 1, 0, _ 0, 1, 0, 1, 0, 0, _ 0, 1, 2, 1, 1, 0, _ 0, 2, 1, 0, 1, 0, _ 2, 1, 0, 0, 1, 2, _ 0, 1, 1, 0, 2, 0, _ 1, 0, 1, 2, 0, 0, _ 1, 1}, New Integer() {3, 1, 1, 1, 0, 3, _ 1, 1, 0, 1, 3, 1, _ 0, 1, 1, 3, 0, 1, _ 1, 1, 2, 1, 1, 0, _ 0, 2, 1, 0, 1, 0, _ 2, 1, 0, 0, 1, 2, _ 0, 1, 1, 0, 2, 0, _ 1, 0, 1, 2, 0, 0, _ 1, 1}} Dim p4D = New Integer() {0, 0, 1, -1, 0, 0, _ 0, 1, 0, -1, 0, 0, _ 1, 0, 0, -1, 0, 0, _ -1, 1, 0, 0, 0, 0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