GACCUM_TRAN_MATRIX(3NCARG)

πŸ¦‹ GACCUM_TRAN_MATRIX πŸ¦‹

okay so bestie, welcome to the NCAR GRAPHICS corner of the 3NCARG manual πŸ’… this one's about gaccum_tran_matrix and honestly? it's giving matrix math main character energy ✨


✨ NAME ✨

GACCUM_TRAN_MATRIX β€” Accumulate transformation matrix πŸŽ€


🌸 DESCRIPTION 🌸

gaccum_tran_matrix (Accumulate transformation matrix) β€” it builds a GKS segment transformation matrix by taking a matrix you already have and composing it with a shift vector, a rotation angle, and X and Y scale factors to make a whole new transformation matrix. no cap. 🫢

and the rotation + scaling? those happen with respect to a user-defined fixed point, because obviously we're not just rotating into the void πŸ’€


πŸŽ€ SYNOPSIS πŸŽ€

#include <ncarg/gks.h>

void gaccum_tran_matrix(const Gtran_matrix t_matrix, const Gpoint
*point, const Gvec *shift, Gdouble angle, const Gvec *scale,
Gcoord_switch coord_switch, Gtran_matrix tran_matrix);

πŸ’– DESCRIPTION (cont.) β€” the actual arguments, bestie πŸ’–

  • t_matrix (Gfloat, Input) β€” a 2x3 GKS transformation matrix. your starting point, your canvas, your blueprint 🌈
  • point.x (Gfloat, Input) β€” the X coordinate value for a fixed point, and that fixed point is what the scaling and rotation parts of the output transformation happen around. point.x is either in world coordinates or normalized device coordinates, depending on how coord_switch is set (more on that below, don't worry πŸ’…).
  • point.y (Gfloat, Input) β€” the Y coordinate value for that same fixed point used for the scaling and rotation parts of the output transformation. also either world coordinates or normalized device coordinates depending on coord_switch. slay ✨
  • shift.delta_x (Gfloat, Input) β€” the X component of a shift vector used for the scaling part of the output transformation. shift.delta_x is either in world coordinates or normalized device coordinates, depending on the setting of coord_switch. yes we know, it says the scaling part, that's just what the manpage says, we don't make the rules 😭
  • shift.delta_y (Gfloat, Input) β€” the Y component of that shift vector, used for the scaling part of the output transformation. again: world coordinates or normalized device coordinates depending on coord_switch.
  • angle (Input) β€” the rotation angle, in radians, used for the rotation part of the output transformation. radians bestie, not degrees, do not come at me with 45 and expect a 45-degree rotation 🧚
  • scale.delta_x (Gfloat, Input) β€” the X coordinate scale factor used in the scaling part of the output transformation.
  • scale.delta_y (Gfloat, Input) β€” the Y coordinate scale factor used in the scaling part of the output transformation.
  • coord_switch (Input) β€” a coordinate switch that tells us whether the values for point and shift are in world coordinates or normalized device coordinates. possible values include:
    • GCOORD_WC β€” World coordinates 🌍
    • GCOORD_NDC β€” Normalized device coordinates πŸ“
  • tran_matrix (Gfloat, Output) β€” a 2x3 array holding the GKS transformation matrix, in a form you can feed straight into other GKS functions like gset_seg_tran. it's built by composing the scale, rotate, and shift inputs described above with the original input matrix t_matrix. iconic behavior honestly πŸ‘‘

🌈 USAGE 🌈

if you're using world coordinates, then the shift vector and the fixed point get transformed by the current normalization transformation. periodt.

the order the transformations get applied in is: input matrix, then scale, then rotate, then shift. write that down πŸ“

elements tran_matrix[0][2] and tran_matrix[1][2] are in normalized device coordinates, and all the other elements of tran_matrix are unitless.

so here's the tea: gaccum_tran_matrix can build more general transformation matrices than geval_tran_matrix can. and the most common usage of gaccum_tran_matrix is to change the order in which scale, rotate, and shift get applied β€” because in geval_tran_matrix that order is locked in and you cannot move it, sorry babe πŸ”’

the example below shows how to build a transformation matrix that shifts first and then rotates, which is exactly the kind of glow-up this function exists for πŸ’…βœ¨


πŸ”₯ EXAMPLE πŸ”₯

assuming the input matrix t_matrix starts out as the identity, this code:

pi = 3.1415926;
point.x = point.y = 0.5;
shift.delta_x = 0.25;
shift.delta_y = 0.;
scale.delta_x = 1.0;
scale.delta_y = 1.0;
gaccum_tran_matrix(t_matrix,&point,&shift,0.,&scale,GCOORD_WC,tout);
for( i = 0; i < 2; i++ ) {
    for( j = 0; j < 3; j++ ) {
        t_matrix[i][j] = tout[i][j];
    }
}
shift.delta_x = 0.;
shift.delta_y = 0.;
gaccum_tran_matrix(t_matrix,&point,&shift,45.*pi/180.,&scale,GCOORD_WC,tout);

would produce a transformation matrix in tout that shifts by (.25,0.) first, and then rotates by 45 degrees. ate and left no crumbs πŸ“


πŸ‘‘ ACCESS πŸ‘‘

to use the GKS C-binding routines, you load the ncarg_gks and ncarg_c libraries. that's it, that's the whole vibe.


πŸ¦‹ SEE ALSO πŸ¦‹

Online: geval_tran_matrix(3NCARG), gclose_seg(3NCARG), gcreate_seg(3NCARG), gcopy_seg_ws(3NCARG), gdel_seg(3NCARG), ginq_name_open_seg(3NCARG), ginq_set_seg_names(3NCARG), gset_seg_tran(3NCARG), gks(3NCARG), ncarg_gks_cbind(3NCARG)

Hardcopy: User's Guide for NCAR GKS-0A Graphics; NCAR Graphics Fundamentals, UNIX Version


Copyright (C) 1987-2009 University Corporation for Atmospheric Research The use of this Software is governed by a License Agreement.


okay that's the whole page bestie, go forth and accumulate those transformation matrices responsibly πŸ«ΆπŸ’–

and that's a wrap on the UNIX version from March 1993 of GACCUM_TRAN_MATRIX(3NCARG) β€” mwah, no notes πŸ’…βœ¨