我一直在努力实现Simplex Noise大约一个月,我确实理解使用Simplices来减少所需的计算量以及渐变侧的安全功率.然而,将其实现为任何语言,似乎都是不可能的任务.
在我找到的每一个,每一个,每个代码中,我读到的资源,无处不在,代码似乎都有一个G和一个P表.从一些谷歌搜索和询问周围我了解到他们是一个排列和一个渐变表.他们在做什么?我们为什么需要它们?
我目前的想法是排列表只包含随机值,因此不必在运行时计算它们.
例子:
我在类testclass中有一个构造函数
@safe public nothrow this(ref Socket socket) {
// Inside class modulename.classname
this.socket = socket;
}
Run Code Online (Sandbox Code Playgroud)
但是,当我在main方法中初始化这种类型的对象时,我遇到了一些编译错误.
void main() {
auto variablename = new modulename.classname(
cast(Socket) new TcpSocket() // main.d line 5
);
}
Run Code Online (Sandbox Code Playgroud)
错误:
main.d(5): Error: constructor testmodule.testclass.this (ref
Socket socket) is not callable using argument types (Socket)
main.d(5): Error: no constructor for testclass
Run Code Online (Sandbox Code Playgroud)
为什么我不能通过引用传递套接字?
如何在D中创建静态数组,在编译时未指定该大小?
immutable ulong arrayLength = getArrayLength();
ubyte[arayLength]; // <- How to do this basically
Run Code Online (Sandbox Code Playgroud) 如何创建支持任何大小的静态数组的函数?
就像是:
@safe pure nothrow void fillArray(ref ubyte[] array) {
/**
* How do I make this function support arrays of any
* size; but they don't have to be dynamic?
**/
}
Run Code Online (Sandbox Code Playgroud) 如何创建一个具有设置大小的数组,该数组在编译时是未知的,但是具有未设置的值?
基本上我想要的东西int immutable([length]);
.length
在编译时不知道.显然,这不会编译.
是否有可能在Windows中创建一个GUI程序,它的入口点是'main()'?我该怎么做呢?
我的用途是我想要一个跨平台的应用程序,有一个统一的入口点.
如果使用'perror(errno)',它会自动将错误打印到标准错误输出流.有没有办法在不打印的情况下获得可以打印的值?
我想初始化一个结构并将其返回到Digitalmars D的同一行.我该怎么做?
struct Record {
immutable(ubyte) protocolVersion;
immutable(ubyte) type;
immutable(ushort) requestId;
}
class test {
Record nextRequest() {
ubyte buffer[512];
auto bytesReceived = socketIn.receive(buffer);
if(bytesReceived < 0)
throw new ErrnoException("Error while receiving data");
else if(bytesReceived == 0)
throw new ConnectionClosedException();
return {
protocolVersion:1, //52
type:1, //53
requestId:1 //54
}; //55
} //56
} // 57
Run Code Online (Sandbox Code Playgroud)
这段代码给了我编译错误:
file.d(53): Error: found ':' when expecting ';' following statement
file.d(54): Error: found ':' when expecting ';' following statement
file.d(55): Error: expression expected, not '}' …
Run Code Online (Sandbox Code Playgroud) 我在寻找这个问题的答案时偶然发现了这个话题.
从本质上讲,我所要求的是与该线程中所做的相反.而不是通过它的名字得到枚举的价值,我想通过它的价值得到它的名字.这是怎么做到的?
我在一个模块中有两个D类.我希望A类有一个属性,只能从A类和B类访问.我该怎么做?
class A {
int a = 5; // Make this accessible to, and only to, B.
}
class B {
this(in A pA) {
int b = pA.a;
}
}
Run Code Online (Sandbox Code Playgroud)