RAINBOW *Create_Rainbow() { RAINBOW *New; New = (RAINBOW *)POV_MALLOC(sizeof(RAINBOW), "fog"); New->Distance = Max_Distance; New->Jitter = 0.0; New->Angle = 0.0; New->Width = 0.0; New->Falloff_Width = 0.0; New->Arc_Angle = 180.0; New->Falloff_Angle = 180.0; New->Pigment = NULL; Make_Vector(New->Antisolar_Vector, 0.0, 0.0, 0.0); Make_Vector(New->Right_Vector, 1.0, 0.0, 0.0); Make_Vector(New->Up_Vector, 0.0, 1.0, 0.0); New->Next = NULL; return (New); }
RAINBOW *Create_Rainbow() { RAINBOW *New; New = new RAINBOW; New->Distance = MAX_DISTANCE; New->Jitter = 0.0; New->Angle = 0.0; New->Width = 0.0; New->Falloff_Width = 0.0; New->Arc_Angle = 180.0; New->Falloff_Angle = 180.0; New->Pigment = NULL; Make_Vector(New->Antisolar_Vector, 0.0, 0.0, 0.0); Make_Vector(New->Right_Vector, 1.0, 0.0, 0.0); Make_Vector(New->Up_Vector, 0.0, 1.0, 0.0); New->Next = NULL; return (New); }
PARAMETRIC* Create_Parametric() { PARAMETRIC *New; New = (PARAMETRIC *)POV_MALLOC(sizeof(PARAMETRIC), "parametric"); INIT_OBJECT_FIELDS(New, PARAMETRIC_OBJECT, &Parametric_Methods); Make_Vector(New->container.box.corner1, -1.0, -1.0, -1.0); Make_Vector(New->container.box.corner2, 1.0, 1.0, 1.0); Make_BBox(New->BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); New->Trans = Create_Transform(); New->Function[0] = NULL; New->Function[1] = NULL; New->Function[2] = NULL; New->accuracy = 0.001; New->max_gradient = 1; New->Inverted = false; New->PData = NULL; New->container_shape = 0; return New; }
TRIANGLE *Create_Triangle() { TRIANGLE *New; New = (TRIANGLE *)POV_MALLOC(sizeof(TRIANGLE), "triangle"); INIT_OBJECT_FIELDS(New,TRIANGLE_OBJECT,&Triangle_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New->Distance = 0.0; /* BEG ROSE this three points doesn't belong to the normal vector, created above: END ROSE */ Make_Vector(New->P1, 0.0, 0.0, 0.0); Make_Vector(New->P2, 1.0, 0.0, 0.0); Make_Vector(New->P3, 0.0, 1.0, 0.0); /* * NOTE: Dominant_Axis is computed when Parse_Triangle calls * Compute_Triangle. vAxis is used only for smooth triangles. */ return(New); }
static void calc_bbox(BBOX *BBox, BBOX_TREE **Finite, long first, long last) { long i; DBL tmin, tmax; VECTOR bmin, bmax; BBOX *bbox; Make_Vector(bmin, BOUND_HUGE, BOUND_HUGE, BOUND_HUGE); Make_Vector(bmax, -BOUND_HUGE, -BOUND_HUGE, -BOUND_HUGE); for (i = first; i < last; i++) { bbox = &(Finite[i]->BBox); tmin = bbox->Lower_Left[X]; tmax = tmin + bbox->Lengths[X]; if (tmin < bmin[X]) { bmin[X] = tmin; } if (tmax > bmax[X]) { bmax[X] = tmax; } tmin = bbox->Lower_Left[Y]; tmax = tmin + bbox->Lengths[Y]; if (tmin < bmin[Y]) { bmin[Y] = tmin; } if (tmax > bmax[Y]) { bmax[Y] = tmax; } tmin = bbox->Lower_Left[Z]; tmax = tmin + bbox->Lengths[Z]; if (tmin < bmin[Z]) { bmin[Z] = tmin; } if (tmax > bmax[Z]) { bmax[Z] = tmax; } } Make_BBox_from_min_max(*BBox, bmin, bmax); }
CONE *Create_Cylinder() { CONE *New; New = (CONE *)POV_MALLOC(sizeof(CONE), "cone"); INIT_OBJECT_FIELDS(New, CONE_OBJECT, &Cone_Methods) Make_Vector(New->apex, 0.0, 0.0, 1.0); Make_Vector(New->base, 0.0, 0.0, 0.0); New->apex_radius = 1.0; New->base_radius = 1.0; New->dist = 0.0; New->Trans = Create_Transform(); Set_Flag(New, CYLINDER_FLAG); /* This is a cylinder. */ Set_Flag(New, CLOSED_FLAG); /* Has capped ends. */ /* Default bounds */ Make_BBox(New->BBox, -1.0, -1.0, 0.0, 2.0, 2.0, 1.0); return (New); }
void Compute_Coordinate_Transform(TRANSFORM *trans, const VECTOR origin, VECTOR up, DBL radius, DBL length) { TRANSFORM trans2; VECTOR tmpv; Make_Vector(tmpv, radius, radius, length); Compute_Scaling_Transform(trans, tmpv); if (fabs(up[Z]) > 1.0 - EPSILON) { Make_Vector(tmpv, 1.0, 0.0, 0.0); up[Z] = up[Z] < 0.0 ? -1.0 : 1.0; } else { Make_Vector(tmpv, -up[Y], up[X], 0.0); } Compute_Axis_Rotation_Transform(&trans2, tmpv, acos(up[Z])); Compose_Transforms(trans, &trans2); Compute_Translation_Transform(&trans2, origin); Compose_Transforms(trans, &trans2); }
Ray::Ray(RayType rt, bool shadowTest, bool photon, bool radiosity, bool monochromatic, bool pretrace) { Make_Vector(Origin, 0.0, 0.0, 0.0); Make_Vector(Direction, 0.0, 0.0, 0.0); SetFlags(rt, shadowTest, photon, radiosity, monochromatic, pretrace); hollowRay = true; ClearInteriors(); }
float vf_Count_Percentage(float *init, float *real, float *finish) { float vr[3], dr, vf[3], df; Make_Vector(init, finish, vf); df = Vector_Length(vf); Make_Vector(init, real, vr); dr = Vector_Length(vr); if (df == 0) return 100; return ((100.0f * dr) / df); }
QUADRIC *Create_Quadric() { QUADRIC *New; New = (QUADRIC *)POV_MALLOC(sizeof (QUADRIC), "quadric"); INIT_OBJECT_FIELDS(New, QUADRIC_OBJECT, &Quadric_Methods) Make_Vector (New->Square_Terms, 1.0, 1.0, 1.0); Make_Vector (New->Mixed_Terms, 0.0, 0.0, 0.0); Make_Vector (New->Terms, 0.0, 0.0, 0.0); New->Constant = 1.0; New->Automatic_Bounds = false; return(New); }
void Torus::Normal(VECTOR Result, Intersection *Inter, TraceThreadData *Thread) const { DBL dist; VECTOR P, N, M; /* Transform the point into the torus space. */ MInvTransPoint(P, Inter->IPoint, Trans); /* Get normal from derivatives. */ dist = sqrt(P[X] * P[X] + P[Z] * P[Z]); if (dist > EPSILON) { M[X] = MajorRadius * P[X] / dist; M[Y] = 0.0; M[Z] = MajorRadius * P[Z] / dist; } else { Make_Vector(M, 0.0, 0.0, 0.0); } VSub(N, P, M); /* Transform the normalt out of the torus space. */ MTransNormal(Result, N, Trans); VNormalize(Result, Result); }
static Object P_Query_Tree (Object w) { Window root, parent, *children; Display *dpy; unsigned int i, n; Object v, ret; GC_Node2; Check_Type (w, T_Window); dpy = WINDOW(w)->dpy; Disable_Interrupts; XQueryTree (dpy, WINDOW(w)->win, &root, &parent, &children, &n); Enable_Interrupts; v = ret = Null; GC_Link2 (v, ret); v = Make_Window (0, dpy, root); ret = Cons (v, Null); v = Make_Window (0, dpy, parent); ret = Cons (v, ret); v = Make_Vector (n, Null); for (i = 0; i < n; i++) { Object x; x = Make_Window (0, dpy, children[i]); VECTOR(v)->data[i] = x; } ret = Cons (v, ret); GC_Unlink; return ret; }
static void Do_Average_Normals (const VECTOR EPoint, const TNORMAL *Tnormal, VECTOR normal, Intersection *Inter, const Ray *ray, TraceThreadData *Thread) { int i; BLEND_MAP *Map = Tnormal->Blend_Map; SNGL Value; SNGL Total = 0.0; VECTOR V1,V2; Make_Vector (V1, 0.0, 0.0, 0.0); for (i = 0; i < Map->Number_Of_Entries; i++) { Value = Map->Blend_Map_Entries[i].value; Assign_Vector(V2,normal); Perturb_Normal(V2,Map->Blend_Map_Entries[i].Vals.Tnormal,EPoint,Inter,ray,Thread); VAddScaledEq(V1,Value,V2); Total += Value; } VInverseScale(normal,V1,Total); }
static int find_axis(BSPHERE_TREE **Elements, int first, int last) { int which = X; int i; DBL e, d = - BOUND_HUGE; VECTOR C, mins, maxs; Make_Vector(mins, BOUND_HUGE, BOUND_HUGE, BOUND_HUGE); Make_Vector(maxs, -BOUND_HUGE, -BOUND_HUGE, -BOUND_HUGE); for (i = first; i < last; i++) { Assign_Vector(C, Elements[i]->C); mins[X] = min(mins[X], C[X]); maxs[X] = max(maxs[X], C[X]); mins[Y] = min(mins[Y], C[Y]); maxs[Y] = max(maxs[Y], C[Y]); mins[Z] = min(mins[Z], C[Z]); maxs[Z] = max(maxs[Z], C[Z]); } e = maxs[X] - mins[X]; if (e > d) { d = e; which = X; } e = maxs[Y] - mins[Y]; if (e > d) { d = e; which = Y; } e = maxs[Z] - mins[Z]; if (e > d) { which = Z; } return (which); }
Plane::Plane() : ObjectBase(PLANE_OBJECT) { Make_Vector(Normal_Vector, 0.0, 1.0, 0.0); Distance = 0.0; Trans = NULL; }
BOX *Create_Box() { BOX *New; New = (BOX *)POV_MALLOC(sizeof(BOX), "box"); INIT_OBJECT_FIELDS(New, BOX_OBJECT, &Box_Methods) Make_Vector(New->bounds[0], -1.0, -1.0, -1.0); Make_Vector(New->bounds[1], 1.0, 1.0, 1.0); Make_BBox(New->BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); New->Trans = NULL; return (New); }
void Recompute_Inverse_BBox(BBOX *bbox, TRANSFORM *trans) { int i; VECTOR lower_left, lengths, corner; VECTOR mins, maxs; if (trans == NULL) { return; } Assign_BBox_Vect(lower_left, bbox->Lower_Left); Assign_BBox_Vect(lengths, bbox->Lengths); Make_Vector(mins, BOUND_HUGE, BOUND_HUGE, BOUND_HUGE); Make_Vector(maxs, -BOUND_HUGE, -BOUND_HUGE, -BOUND_HUGE); for (i = 1; i <= 8; i++) { Assign_Vector(corner, lower_left); corner[X] += ((i & 1) ? lengths[X] : 0.0); corner[Y] += ((i & 2) ? lengths[Y] : 0.0); corner[Z] += ((i & 4) ? lengths[Z] : 0.0); MInvTransPoint(corner, corner, trans); if (corner[X] < mins[X]) { mins[X] = corner[X]; } if (corner[X] > maxs[X]) { maxs[X] = corner[X]; } if (corner[Y] < mins[Y]) { mins[Y] = corner[Y]; } if (corner[Y] > maxs[Y]) { maxs[Y] = corner[Y]; } if (corner[Z] < mins[Z]) { mins[Z] = corner[Z]; } if (corner[Z] > maxs[Z]) { maxs[Z] = corner[Z]; } } /* Clip bounding box at the largest allowed bounding box. */ if (mins[X] < -BOUND_HUGE / 2) { mins[X] = -BOUND_HUGE / 2; } if (mins[Y] < -BOUND_HUGE / 2) { mins[Y] = -BOUND_HUGE / 2; } if (mins[Z] < -BOUND_HUGE / 2) { mins[Z] = -BOUND_HUGE / 2; } if (maxs[X] > BOUND_HUGE / 2) { maxs[X] = BOUND_HUGE / 2; } if (maxs[Y] > BOUND_HUGE / 2) { maxs[Y] = BOUND_HUGE / 2; } if (maxs[Z] > BOUND_HUGE / 2) { maxs[Z] = BOUND_HUGE / 2; } Make_BBox_from_min_max(*bbox, mins, maxs); }
static void build_area_table(BBOX_TREE **Finite, long a, long b, DBL *areas) { long i, imin, dir; DBL tmin, tmax; VECTOR bmin, bmax, len; BBOX *bbox; if (a < b) { imin = a; dir = 1; } else { imin = b; dir = -1; } Make_Vector(bmin, BOUND_HUGE, BOUND_HUGE, BOUND_HUGE); Make_Vector(bmax, -BOUND_HUGE, -BOUND_HUGE, -BOUND_HUGE); for (i = a; i != (b + dir); i += dir) { bbox = &(Finite[i]->BBox); tmin = bbox->Lower_Left[X]; tmax = tmin + bbox->Lengths[X]; if (tmin < bmin[X]) { bmin[X] = tmin; } if (tmax > bmax[X]) { bmax[X] = tmax; } tmin = bbox->Lower_Left[Y]; tmax = tmin + bbox->Lengths[Y]; if (tmin < bmin[Y]) { bmin[Y] = tmin; } if (tmax > bmax[Y]) { bmax[Y] = tmax; } tmin = bbox->Lower_Left[Z]; tmax = tmin + bbox->Lengths[Z]; if (tmin < bmin[Z]) { bmin[Z] = tmin; } if (tmax > bmax[Z]) { bmax[Z] = tmax; } VSub(len, bmax, bmin); areas[i - imin] = len[X] * (len[Y] + len[Z]) + len[Y] * len[Z]; } }
SMOOTH_TRIANGLE *Create_Smooth_Triangle() { SMOOTH_TRIANGLE *New; New = (SMOOTH_TRIANGLE *)POV_MALLOC(sizeof(SMOOTH_TRIANGLE), "smooth triangle"); INIT_OBJECT_FIELDS(New,SMOOTH_TRIANGLE_OBJECT,&Smooth_Triangle_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New->Distance = 0.0; /* BEG ROSE The normal vectors are not matching the triangle, given by the points: END ROSE */ Make_Vector(New->P1, 0.0, 0.0, 0.0); Make_Vector(New->P2, 1.0, 0.0, 0.0); Make_Vector(New->P3, 0.0, 1.0, 0.0); Make_Vector(New->N1, 0.0, 1.0, 0.0); Make_Vector(New->N2, 0.0, 1.0, 0.0); Make_Vector(New->N3, 0.0, 1.0, 0.0); /* * NOTE: Dominant_Axis and vAxis are computed when * Parse_Triangle calls Compute_Triangle. */ return(New); }
Parametric::Parametric() : ObjectBase(PARAMETRIC_OBJECT) { Make_Vector(container.box.corner1, -1.0, -1.0, -1.0); Make_Vector(container.box.corner2, 1.0, 1.0, 1.0); Make_BBox(BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); Trans = Create_Transform(); Function[0] = NULL; Function[1] = NULL; Function[2] = NULL; accuracy = 0.001; max_gradient = 1; Inverted = false; PData = NULL; container_shape = 0; }
static void Cone_Normal(VECTOR Result, OBJECT *Object, INTERSECTION *Inter) { CONE *Cone = (CONE *)Object; /* Transform the point into the cones space */ MInvTransPoint(Result, Inter->IPoint, Cone->Trans); /* Calculating the normal is real simple in canonical cone space */ switch (Inter->i1) { case SIDE_HIT: if (Test_Flag(Cone, CYLINDER_FLAG)) { Result[Z] = 0.0; } else { Result[Z] = -Result[Z]; } break; case BASE_HIT: Make_Vector(Result, 0.0, 0.0, -1.0); break; case CAP_HIT: Make_Vector(Result, 0.0, 0.0, 1.0); break; } /* Transform the point out of the cones space */ MTransNormal(Result, Result, Cone->Trans); VNormalize(Result, Result); }
VECTOR *Create_Vector () { VECTOR *New; New = (VECTOR *)POV_MALLOC(sizeof (VECTOR), "vector"); Make_Vector (*New, 0.0, 0.0, 0.0); return (New); }
ISOSURFACE* Create_IsoSurface() { ISOSURFACE * New; New = (ISOSURFACE *)POV_MALLOC(sizeof(ISOSURFACE), "isosurface"); INIT_OBJECT_FIELDS(New, ISOSURFACE_OBJECT, &IsoSurface_Methods) Make_Vector(New->container.box.corner1, -1.0, -1.0, -1.0); Make_Vector(New->container.box.corner2, 1.0, 1.0, 1.0); Make_BBox(New->BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); New->Trans = Create_Transform(); New->Function = NULL; New->accuracy = 0.001; New->max_trace = 1; New->cache = false; New->eval_param[0] = 0.0; // 1.1; // not necessary New->eval_param[1] = 0.0; // 1.4; // not necessary New->eval_param[2] = 0.0; // 0.99; // not necessary New->eval = false; New->closed = true; New->Inv3 = 1; New->container_shape = 0; New->max_gradient = 1.1; New->gradient = 0.0; New->threshold = 0.0; New->mginfo = (ISO_Max_Gradient *)POV_MALLOC(sizeof(ISO_Max_Gradient), "isosurface max_gradient info"); New->mginfo->refcnt = 1; New->mginfo->max_gradient = 0.0; New->mginfo->gradient = 0.0; // not really necessary yet [trf] New->mginfo->eval_max = 0.0; New->mginfo->eval_cnt = 0.0; New->mginfo->eval_gradient_sum = 0.0; return New; }
void Compute_Bicubic_Patch_BBox(BICUBIC_PATCH *Bicubic_Patch) { int i, j; VECTOR Min, Max; Make_Vector(Min, BOUND_HUGE, BOUND_HUGE, BOUND_HUGE); Make_Vector(Max, -BOUND_HUGE, -BOUND_HUGE, -BOUND_HUGE); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { Min[X] = min(Min[X], Bicubic_Patch->Control_Points[i][j][X]); Min[Y] = min(Min[Y], Bicubic_Patch->Control_Points[i][j][Y]); Min[Z] = min(Min[Z], Bicubic_Patch->Control_Points[i][j][Z]); Max[X] = max(Max[X], Bicubic_Patch->Control_Points[i][j][X]); Max[Y] = max(Max[Y], Bicubic_Patch->Control_Points[i][j][Y]); Max[Z] = max(Max[Z], Bicubic_Patch->Control_Points[i][j][Z]); } } Make_BBox_from_min_max(Bicubic_Patch->BBox, Min, Max); }
static void Transform_Polygon(OBJECT *Object, TRANSFORM *Trans) { VECTOR N; POLYGON *Polyg = (POLYGON *)Object; Compose_Transforms(Polyg->Trans, Trans); Make_Vector(N, 0.0, 0.0, 1.0); MTransNormal(Polyg->S_Normal, N, Polyg->Trans); VNormalizeEq(Polyg->S_Normal); Compute_Polygon_BBox(Polyg); }
DISC *Create_Disc () { DISC *New; New = (DISC *)POV_MALLOC(sizeof (DISC), "disc"); INIT_OBJECT_FIELDS(New, DISC_OBJECT, &Disc_Methods) Make_Vector (New->center, 0.0, 0.0, 0.0); Make_Vector (New->normal, 0.0, 0.0, 1.0); New->iradius2 = 0.0; New->oradius2 = 1.0; New->d = 0.0; New->Trans = Create_Transform(); /* Default bounds */ Make_BBox(New->BBox, -1.0, -1.0, -Small_Tolerance, 2.0, 2.0, 2.0 * Small_Tolerance); return (New); }
POLYGON *Create_Polygon() { POLYGON *New; New = (POLYGON *)POV_MALLOC(sizeof(POLYGON), "polygon"); INIT_OBJECT_FIELDS(New,POLYGON_OBJECT,&Polygon_Methods) New->Trans = Create_Transform(); Make_Vector(New->S_Normal, 0.0, 0.0, 1.0); New->Data = NULL; return (New); }
PLANE *Create_Plane() { PLANE *New; New = (PLANE *)POV_MALLOC(sizeof (PLANE), "plane"); INIT_OBJECT_FIELDS(New,PLANE_OBJECT,&Plane_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New ->Distance = 0.0; New->Trans = NULL; return(New); }
// // MAKE_Vector: C // void MAKE_Vector(REBVAL *out, enum Reb_Kind kind, const REBVAL *arg) { // CASE: make vector! 100 if (IS_INTEGER(arg) || IS_DECIMAL(arg)) { REBINT size = Int32s(arg, 0); if (size < 0) goto bad_make; REBSER *ser = Make_Vector(0, 0, 1, 32, size); Val_Init_Vector(out, ser); return; } TO_Vector(out, kind, arg); // may fail() return; bad_make: fail (Error_Bad_Make(kind, arg)); }
void camera_Move(int pressed_key, int left, int back, CAMERA_ANIMATION *cam, float fpq) { float v[3], vR[3]; key[pressed_key] = 0; kam_pol_get((BOD *)&cam->finish.Position, &cam->finish.r, &cam->finish.fi, &cam->finish.Distance); kam_3ds_get((BOD *)&cam->finish.Position, (BOD *)&cam->finish.Target, &cam->finish.Roll); cam->finish.Position[1] = cam->finish.Target[1]; Make_Vector(cam->finish.Target,cam->finish.Position, v); Normalize_Vector(v); if(!left) { Normal_Vector(v, vR); Multiple_Vector(vR, 4); Add_Vector(cam->finish.Target, vR, cam->finish.Position); } else if(left == 1) { Normal_Vector(v, vR); Multiple_Vector(vR, 4); Inverse_Vector(vR, vR, 3); Add_Vector(cam->finish.Target, vR, cam->finish.Position); } if(!back) { Multiple_Vector(v, 4); Inverse_Vector(v, v, 3); Add_Vector(cam->finish.Target, v, cam->finish.Position); } else if(back == 1) { Multiple_Vector(v, 4); Add_Vector(cam->finish.Target, v, cam->finish.Position); } camera_Go(cam, fpq); }