Visual Studio实现玫瑰花(c语言)

话不多说,为了装逼!上代码!

#include <stdio.h>
#include <math.h>
 
const int max_iterations = 128;
const float stop_threshold = 0.01f;
const float grad_step = 0.01f;
const float clip_far = 10.0f;
 
const float PI = 3.14159265359f;
const float PI2 = 6.28318530718f;
const float DEG_TO_RAD = PI / 180.0f;
 
typedef struct {
    float x, y; } vec2;
typedef struct {
    float x, y, z; } vec3;
typedef struct {
    float m[9]; } mat3;
 
const vec3 light_pos = {
    20.0f, 50.0f, 20.0f };
 
float min(float a, float b) {
    return a < b ? a : b; }
float max(float a, float b) {
    return a > b ? a : b; }
float clamp(float f, float a, float b) {
    return max(min(f, b), a); }
vec2 make2(float x, float y) {
    vec2 r = {
    x, y }; return r; }
vec2 add2(vec2 a, vec2 b) {
    vec2 r = {
    a.x + b.x, a.y + b.y }; return r; }
vec2 sub2(vec2 a, vec2 b) {
    vec2 r = {
    a.x - b.x, a.y - b.y }; return r; }
float dot2(vec2 a, vec2 b) {
    return a.x * b.x + a.y * b.y; }
float length2(vec2 v) {
    return sqrt(dot2(v, v)); }
vec3 make3(float x, float y, float z) {
    vec3 r = {
    x, y, z }; return r; }
vec3 add3(vec3 a, vec3 b) {
    vec3 r = {
    a.x + b.x, a.y + b.y, a.z + b.z 
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

范思哲❥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值