|
|
Posting this in PNU since it seems like it ought to be a simple task, and
probably one that would be commonly used if it was.
I think this also touches on the discussion of what can be done to help make POV
better and more accessible to new users, to help them start using POV as a
tool-of-choice, rather than something to be avoided and abandoned out of
frustration.
The transform {} command was pretty confusing to implement - it's one of those
things where it seems like you're layering the same command, and it was sort of
hard to grasp how to go from transforming values to applying that transform to
an object. I can appreciate how such a thing could be a stumbling block for a
new user unaccustomed to POV-Ray's SDL command structure. [A big thank you to
all who have helped me learn the ins and outs of coding complex scenes!]
Now to the task at hand:
------------------------
I'm trying to extend the ends of a box object between 2 points - mimicking a
cylinder.
I naively tried the VRotationD macro in math.inc, and then discovered my error
of trying to simply rotate around Z after rotating around Y upon further
extended thought. Rotating around Y now requires rotation around some new
non-cardinal axis which I designate as Q.
I have a range of points that all work, when I just change the endpoint y, but
when I change either x or z in the same fashion, all hell breaks loose.
Is this another erroneous implementation on my part?
Also,
While working on this, I also noticed that there was a lot of stuff commented
out in the math.inc file - I'm wondering why, and if all that stuff should still
be there. Perhaps it's time to take a look through some of those macros, update
the code (if necessary), and add some clarifying comments.
Especially useful would be a new directory in the Insert Menu with practical
examples for usage, or at least a few lines of fully working code in the include
file itself that could be cut and pasted directly into a scene.
=====================================================================
// test code for aligning a box between two vectors (points)
// Bald Eagle 2016
#version 3.7;
global_settings {
assumed_gamma 1.0
ambient_light color rgb <1, 1, 1>
}
include "colors.inc"
include "math.inc"
include "transforms.inc"
#declare Camera_Origin = camera {
location <0, 0, 0>
right x*image_width/image_height
look_at <0, 0, 0.01>}
#declare Camera_Angle = camera {
location <10, 10, 5>
right x*image_width/image_height
look_at <5, 5, 5>}
#declare Camera_Front = camera {
location <5, 5, -20.0>
//location <0.0, 12, -10.0>
right x*image_width/image_height
look_at <5, 5, 0>}
#declare Camera_Rear = camera {
location <0.0, -100.0, -300.0>
right x*image_width/image_height
look_at <0, 0, 0>}
#declare Camera_Top = camera {
location <5, 25.0, 5>
right x*image_width/image_height
look_at <5, 0, 5>}
#declare Camera_Iso = camera {
location <-50, 0, 0>
right x*image_width/image_height
look_at <0, 0, 0>}
//####################
//camera {Camera_Front}
//camera {Camera_Top}
#declare Fraction = 8;
//#declare Camera_Position = <5, 25, 5> ; // top view
#declare Camera_Position = <5, 5, -30> ; // front view
//#declare Camera_Position = <25, 5, 5> ; // right view
#declare Camera_Look_At = <5, 5, 5> ;
camera {
orthographic
right x*image_width/(2*Fraction)
up y*image_height/(2*Fraction)
location Camera_Position
look_at Camera_Look_At
}
//####################
light_source{ <10, 50, -50> color rgb <1, 1, 1>} // White top
// Create an infinite sphere around scene and allow any pigment on it
sky_sphere{ pigment { gradient <0,1,0>
color_map { [0.00 rgb <0.6,0.7,1.0>]
[0.35 rgb <0.0,0.1,0.8>]
[0.65 rgb <0.0,0.1,0.8>]
[1.00 rgb <0.6,0.7,1.0>]
}
scale 2
} // end of pigment
} //end of skysphere -------------------------------------
//#declare Point1 = <5, 5, 5>;
//#declare Point2 = <10, 10, 10>;
#declare DataSet = 3;
#switch (DataSet)
#case(0)
#declare StartArray = array [5] {
<5, 5, 5>,
<1, 4, 9>,
<-10, 7, -3>,
<6, 3, 9>,
<4, -8, 0>}
#declare EndArray = array [5] {
<10, 10, 10>,
<-6, 12, 3>,
<-5, 2, -8>,
<12, -10, 12>,
<-5, -4, 10>}
#break
#case(1)
#declare StartArray = array [5] {
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>}
#declare EndArray = array [5] {
<10, 10, 10>,
<10, 7, 10>,
<10, 4, 10>,
<10, 1, 10>,
<10, -2, 10>}
#break
#case(2)
#declare StartArray = array [5] {
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>}
#declare EndArray = array [5] {
<10, 10, 10>,
<10, 7, 7>,
<10, 4, 4>,
<10, 1, 1>,
<10, -2, -2>}
#break
#case(3)
#declare StartArray = array [5] {
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>,
<5, 5, 5>}
#declare EndArray = array [5] {
<10, 10, 10>,
<7, 7, 10>,
<4, 4, 10>,
<1, 1, 10>,
<-2, -2, 10>}
#break
#end
#declare Strut = 0.5;
#declare Axes = 0.2;
sphere {<0, 0, 0> 0.5 pigment {Gray50} }
cylinder {<0, 0, 0>, <10, 0, 0> Axes pigment {Red*0.5}}
cylinder {<0, 0, 0>, <0, 10, 0> Axes pigment {Green*0.5}}
cylinder {<0, 0, 0>, <0, 0, 10> Axes pigment {Blue*0.5}}
#for (Test, 0, min(dimension_size (StartArray, 1), dimension_size (EndArray,
1))-1 )
#debug concat( " Test = ", str(Test, 3, 1), "\n")
#declare Point1 = StartArray [Test];
#declare Point2 = EndArray [Test];
#declare StrutLength = vlength(Point2 - Point1);
#declare IBeam = box {<0, -Strut/2, -Strut/2>, <StrutLength, Strut/2, Strut/2>}
sphere {Point1 0.5 pigment {Orange*0.5} }
sphere {Point2 0.5 pigment {Violet*0.5} }
cylinder {Point1, Point2, Strut/2 texture {pigment {White} finish {specular
0.8}} }
#declare CurrentVector = (Point2 - Point1);
//--------------------------------------------------------------------------------------------------
#declare CurrentVectorX = VProject_Plane (CurrentVector, <1, 0, 0>); // x is
normal to the z-y plane
#declare CurrentVectorY = VProject_Plane (CurrentVector, <0, 1, 0>); // y is
normal to the x-z plane
#declare CurrentVectorZ = VProject_Plane (CurrentVector, <0, 0, 1>); // z is
normal to the x-y plane
#declare XDeg = VRotationD(<StrutLength, 0, 0>, CurrentVectorX, <1, 0, 0>);
#declare YDeg = VRotationD(<StrutLength, 0, 0>, CurrentVectorY, <0, 1, 0>);
#declare YTransform = transform { rotate y*YDeg };
#declare YRotated = vtransform (<StrutLength, 0, 0>, YTransform);
#declare PivotAxis = VPerp_To_Plane(YRotated, Point2);
#declare QDeg = VRotationD(YRotated, CurrentVector, PivotAxis);
#declare QTransform = transform { Axis_Rotate_Trans(PivotAxis, QDeg) };
#declare NewIBeam = object {IBeam rotate x*XDeg transform YTransform transform
QTransform};
//--------------------------------------------------------------------------------------------------
cylinder {0, PivotAxis, Strut/2 translate Point1 texture {pigment {Gray50}
finish {specular 0.8}} }
//object {IBeam rotate z*ZDeg translate Point1 pigment {Blue} }
object {IBeam translate Point1 pigment {rgbt <1, 0, 0, 0.8>} }
object {IBeam transform YTransform translate Point1 pigment {Green} }
object {NewIBeam translate Point1 pigment {Red} }
#end // end for Test
Post a reply to this message
|
|