struct xobject *t1_Xform( register struct xobject *obj, /* object to transform */ register DOUBLE M[2][2]) /* transformation matrix */ { if (obj == NULL) return(NULL); if (obj->type == FONTTYPE) { register struct font *F = (struct font *) obj; F = UniqueFont(F); return((struct xobject*)F); } if (obj->type == PICTURETYPE) { /* In the case of a picture, we choose both to update the picture's transformation matrix and keep the handles up to date. */ register struct picture *P = (struct picture *) obj; register struct segment *handles; /* temporary path to transform handles */ P = UniquePicture(P); handles = PathSegment(LINETYPE, P->origin.x, P->origin.y); handles = Join(handles, PathSegment(LINETYPE, P->ending.x, P->ending.y) ); handles = (struct segment *)Xform((struct xobject *) handles, M); P->origin = handles->dest; P->ending = handles->link->dest; KillPath(handles); return((struct xobject *)P); } if (ISPATHTYPE(obj->type)) { struct XYspace pseudo; /* local temporary space */ PseudoSpace(&pseudo, M); return((struct xobject *) PathTransform((struct segment *)obj, &pseudo)); } if (obj->type == SPACETYPE) { register struct XYspace *S = (struct XYspace *) obj; /* replaced ISPERMANENT(S->flag) with S->references > 1 3-26-91 PNM */ if (S->references > 1) S = CopySpace(S); else S->ID = NEXTID; MatrixMultiply(S->tofract.normal, M, S->tofract.normal); /* * mark inverted matrix invalid: */ S->flag &= ~HASINVERSE(ON); FillOutFcns(S); return((struct xobject *) S); } return(ArgErr("Untransformable object", obj, obj)); }
void PseudoSpace(struct XYspace *S, /* coordinate space structure to fill out */ double M[2][2]) /* matrix that will become 'tofract.normal' */ { S->type = SPACETYPE; S->flag = ISPERMANENT(ON) + ISIMMORTAL(ON); S->references = 2; /* 3-26-91 added PNM */ S->tofract.normal[0][0] = M[0][0]; S->tofract.normal[1][0] = M[1][0]; S->tofract.normal[0][1] = M[0][1]; S->tofract.normal[1][1] = M[1][1]; FillOutFcns(S); }
void InitSpaces(void) { IDENTITY->type = SPACETYPE; FillOutFcns(IDENTITY); contexts[NULLCONTEXT].normal[1][0] = contexts[NULLCONTEXT].normal[0][1] = contexts[NULLCONTEXT].inverse[1][0] = contexts[NULLCONTEXT].inverse[0][1] = 0.0; contexts[NULLCONTEXT].normal[0][0] = contexts[NULLCONTEXT].normal[1][1] = contexts[NULLCONTEXT].inverse[0][0] = contexts[NULLCONTEXT].inverse[1][1] = 1.0; USER->flag |= ISIMMORTAL(ON); CoerceInverse(USER); }