Logo by Khaotik - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Support us via Flattr FLATTR Link
 
*
Welcome, Guest. Please login or register. March 29, 2024, 02:36:57 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: DE tetrahedron  (Read 1163 times)
0 Members and 1 Guest are viewing this topic.
SCORPION
Conqueror
*******
Posts: 104


« on: October 30, 2014, 12:52:56 PM »

It is impossible to write the function DE Tetrahedron.
That's the way it turns out, a normal Tetrahedron - no. What is wrong?

Code:
#include "DE-Raytracer.frag"

float DE(vec3 p) {

return (max(abs(-p.x-p.y-p.z), 0.0) -0.5 +max(abs(-p.x+p.y-p.z) ,0.0)-0.5 +max(abs(-p.x+p.y+p.z),0.0))-0.5;

}
Logged
claude
Fractal Bachius
*
Posts: 563



WWW
« Reply #1 on: October 30, 2014, 02:19:22 PM »

Here's one I came up with by trial and error after reading http://mathworld.wolfram.com/Point-PlaneDistance.html

Not sure why it works (I just fiddled with it until it did).  There's probably a better way.

Code:
#include "DE-Raytracer.frag"

float  DE(vec3 z) {
  float d1 = dot(z, normalize(vec3( 1.0,  1.0,  1.0))) + 1.0;
  float d2 = dot(z, normalize(vec3 (1.0, -1.0, -1.0))) + 1.0;
  float d3 = dot(z, normalize(vec3(-1.0  ,1.0, -1.0))) + 1.0;
  float d4 = dot(z, normalize(vec3(-1.0, -1.0,  1.0))) + 1.0;
  return -min(min(min(d1, d2), d3), d4);
}
Logged
SCORPION
Conqueror
*******
Posts: 104


« Reply #2 on: October 30, 2014, 02:38:54 PM »

Thanks, it works!
so to simplify

Code:
#include "DE-Raytracer.frag"

float  DE(vec3 z) {
  float d1 = dot(z,(vec3( 1.0,  1.0,  1.0)));
  float d2 = dot(z,(vec3 (1.0, -1.0, -1.0)));
  float d3 = dot(z,(vec3(-1.0  ,1.0, -1.0)));
  float d4 = dot(z,(vec3(-1.0, -1.0,  1.0)));
  return -min(min(min(d1, d2), d3), d4)-1;
}

Perhaps there is another way, but I have not found ...
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
surface area of sierpinski tetrahedron IFS - Iterated Function Systems Karl131058 3 4438 Last post June 26, 2008, 08:33:35 AM
by Karl131058
Tetrahedron _ Winter Images Showcase (Rate My Fractal) vinz 0 809 Last post June 21, 2013, 12:05:04 PM
by vinz

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.127 seconds with 25 queries. (Pretty URLs adds 0.004s, 2q)