POV-Ray : Newsgroups : povray.binaries.images : Rotating isosurface cylinder : Re: Rotating isosurface cylinder Server Time
28 Apr 2024 00:54:08 EDT (-0400)
  Re: Rotating isosurface cylinder  
From: scott
Date: 12 Oct 2016 03:10:59
Message: <57fde203$1@news.povray.org>
> After trying some other stuff, I also have;
> sqrt(
>  pow(y-Edge,2)
>  +pow(z-Edge,2)
>
> +pow(x-select(min(x-Inside_length,0),max(x,Inside_corner),min(x,Inside_length)),2)
>
> )-Block_Round_corner
>
> Witch seems to give a cylinder with rounded ends.
> I can't seem to rotate this ether.
>
> Suggestions, hints?

To rotate the shape by (eg) 30 degrees about the z axis, you need to 
replace x,y & z in your function with x,y,z rotated by -30 degrees about 
the z axis.

For rotation about z, you need:

( from https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations )

x' = x*cos(a) - y*sin(a)
y' = x*sin(a) + y*cos(a)
z' = z

Putting those into your function above you get something like:

#local a = radians(30);

sqrt(
  pow((x*sin(a)+y*cos(a))-Edge,2)
  +pow(z-Edge,2)


+pow((x*cos(a)-y*sin(a))-select(min((x*cos(a)-y*sin(a))-Inside_length,0),max((x*cos(a)-y*sin(a)),Inside_corner),min((x*cos(a)-y*sin(a)),Inside_length)),2)
)-Block_Round_corner


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.