]> O.S.I.I.S - jp/vkvg.git/commitdiff
store result of cos()
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 30 Oct 2022 06:59:06 +0000 (07:59 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 1 Mar 2023 17:56:44 +0000 (18:56 +0100)
src/vkvg_context_internal.c

index 534211756330dd23124e589c10163eb2c7014718..d6b529b5919c361bd9d4633aa47fde61e6dbe0f7 100644 (file)
@@ -977,8 +977,8 @@ bool _build_vb_step(VkvgContext ctx, stroke_context_t* str, bool isCurve){
                alpha = -alpha;
 
        float halfAlpha = alpha / 2.f;
-
-       float lh = str->hw / cosf(halfAlpha);
+       float cosHalfAlpha = cosf(halfAlpha);
+       float lh = str->hw / cosHalfAlpha;
        vec2 bisec_n_perp = vec2_perp(bisec_n);
 
        //limit bisectrice length
@@ -1000,7 +1000,7 @@ bool _build_vb_step(VkvgContext ctx, stroke_context_t* str, bool isCurve){
                        vnPerp = vec2_perp (v0n);
                vec2 vHwPerp = vec2_mult_s (vnPerp, str->hw);
 
-               double lbc = cosf(halfAlpha) * rlh;
+               double lbc = cosHalfAlpha * rlh;
                if (det < 0.f) {
                        rlh_inside_pos  = vec2_add (vec2_add (vec2_mult_s(vnPerp, -lbc), vec2_add(p0, bisec)), vHwPerp);
                        rlh_outside_pos = vec2_sub (p0, vec2_mult_s (bisec_n_perp, lh));
@@ -1029,7 +1029,7 @@ bool _build_vb_step(VkvgContext ctx, stroke_context_t* str, bool isCurve){
 
        if (join == VKVG_LINE_JOIN_MITER){
                if (lh > str->lhMax) {//miter limit
-                       double x = (lh - str->lhMax) * cosf (halfAlpha);
+                       double x = (lh - str->lhMax) * cosHalfAlpha;
                        vec2 bisecPerp = vec2_mult_s (bisec_n, x);
                        bisec = vec2_mult_s (bisec_n_perp, str->lhMax);
                        if (det < 0) {