contributed by < Holycung
>
2020q3 Homework7 (quiz7) 題目
給定兩個函式實作:
int funcA(int i)
{
if (i == 0)
return 0;
return 5 * funcA(i - 1);
}
int funcB(int i)
{
if (i == 0)
return 0;
return funcB(i - 1);
}
以 tail recursion 的觀點,請從下列選項挑出正確的陳述。
根據 Tail call 當中的 Syntactic form 範例有提到如下。
control must return to the caller to allow it to inspect or modify the return value before returning it.
所以在最後 return 時還有做運算或是 if else 都算是在 tail position,所以這邊只有 funcB
是 Tail recursion。
contributed by < Holychung > 2020q3 Homework5 (render) 題目 Outline [TOC] 背景知識 在開始 trace code 之前可以先閱讀 Casting Wolf3D-style Rays with an FPGA and Arduino,當中有提到要撰寫一個 ray casting engine 有兩個方法,其中一個比較直接明瞭的是 Lode's Computer Graphics Tutorial,強烈建議先讀完這篇。 我在讀這篇的時候順便做了點筆記,因為篇幅太長就記錄到 研讀筆記: Raycasting。
Jan 6, 2021source Introduction Raycasting 是一個算繪的技巧,在 2D 呈現 3D 的視野。在電腦運算不夠快的時候是沒辦法跑 3D 引擎,這時候 raycasting 就是一個好辦法。 Raycasting 速度非常的快,因為只需要計算完螢幕上每個垂直的線就好,使用這個方法著名的遊戲 Wolfenstein 3D (德軍總部3D)。 The Basic Idea 基本的 raycasting 觀念是地圖是一個 2D 網狀方格,每一個方格都是 0 (= no wall) 或是正數 (= wall with a certain color or texture)。
Jan 5, 2021source 全文主要是翻譯原文,並記錄自己的閱讀。 Introduction 在這篇文章中我們的目的是建構一個指向 Shape 物件的指標陣列,每一個 Shape 指向物件 Circle、Square、Goat 等不同物件,皆以純 C 實現。 Airticle 先建立三個結構。
Jan 4, 2021antirez/linenoise linenoise 這個 function 是整個程式主要的 API,一開始會檢查是否是 tty,然後在看終端機是否有支援,有支援了話就會呼叫 linenoiseRaw。 char *linenoise(const char *prompt) { char buf[LINENOISE_MAX_LINE]; int count; if (!isatty(STDIN_FILENO)) {
Jan 4, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up