python – Converting Integers to roman between 1 and 1000

Below is my code for the problem:

ItoR = {
1: 'I',
4: 'IV',
5: 'V',
9: 'IX',
10: 'X',
40: 'XL',
50: 'L',
90: 'XC',
100: 'C',
400: 'CD',
500: 'D',
900: 'CM',
1000: 'M'
}

def convertItoR(number):
    number_str = str(number)
    number_len = len(number_str)


    rom_str = ''
    for i in range(number_len):
        # Extracting the digit
        digit = int(number_str(i))
        position = number_len - i - 1
        num_pos = digit * 10 ** position

        print(num_pos)

        # Converting digit to roman string
        if num_pos in ItoR.keys():
            rom_str += ItoR(num_pos)

        elif digit > 1 and digit < 4:
            first = 1 * 10 ** position
            rom_str += ItoR(first) * digit
        
        elif digit > 5 and digit < 9:
            first = 1 * 10 ** position
            fifth = 5 * 10 ** position
            rom_str += ItoR(fifth) + ItoR(first) * (digit - 5) 

        print(rom_str)

    return rom_str

Can it be optimized?

converting RE to DFA (total machine)

Is my solution correct or not as I am trying to understand the basics of automata. Took a question from a(b*|a) a book and trying to solve it. Here is my solution but I am not sure is it correct with a total machine?

enter image description here

Converting a text file to xml using python

line1:address Time(s) ax(g) ay(g) az(g) wx(deg/s) wy(deg/s) wz(deg/s) AngleX(deg) AngleY(deg) AngleZ(deg) T(°)
line1:0x50 19:45:20.876 1.0161 -0.0034 0.0093 0.0000 0.0000 0.0000 -26.3562 -89.4397 104.4745 0.0000
line1:0x50 19:45:20.925 1.0156 -0.0039 0.0117 0.0000 0.0000 0.0000 -26.2848 -89.4397 104.3481 0.0000
line1:0x50 19:45:21.058 1.0151 -0.0059 0.0068 0.0000 0.0000 0.0000 -25.7574 -89.4452 103.8593 0.0000
line1:0x50 19:45:21.124 1.0171 -0.0034 0.0068 0.0000 0.0000 0.0000 -25.5597 -89.4507 103.6615 0.0000
line1:0x50 19:45:21.223 1.0151 -0.0029 0.0088 0.0000 0.0000 0.0000 -25.9717 -89.4507 104.1119 0.0000
line1:0x50 19:45:21.362 1.0161 -0.0044 0.0073 0.0000 0.0000 0.0000 -26.1530 -89.4507 104.2218 0.0000
line1:0x50 19:45:21.495 1.0161 -0.0034 0.0073 0.0000 0.0000 0.0000 -26.0101 -89.4507 104.0186 0.0000
line1:0x50 19:45:21.520 1.0156 -0.0029 0.0088 0.0000 0.0000 0.0000 -26.1420 -89.4507 104.1064 0.0000
line1:0x50 19:45:21.618 1.0176 -0.0024 0.0073 0.0000 0.0000 0.0000 -25.8069 -89.4507 103.7823 0.0000
line1:0x50 19:45:21.726 1.0146 -0.0063 0.0078 0.0000 0.0000 0.0000 -25.7355 -89.4507 103.6890 0.0000
line1:0x50 19:45:21.817 1.0161 -0.0063 0.0088 0.0000 0.0000 0.0000 -26.2354 -89.4562 104.1779 0.0000
line1:0x50 19:45:21.923 1.0166 -0.0044 0.0044 0.0000 0.0000 0.0000 -26.0980 -89.4507 104.0021 0.0000
line1:0x50 19:45:22.015 1.0176 -0.0015 0.0093 0.0000 0.0000 0.0000 -26.0486 -89.4507 103.9526 0.0000
line1:0x50 19:45:22.115 1.0151 -0.0034 0.0107 0.0000 0.0000 0.0000 -26.2134 -89.4507 104.1833 0.0000
line1:0x50 19:45:22.250 1.0142 -0.0068 0.0083 0.0000 0.0000 0.0000 -26.1310 -89.4562 104.1284 0.0000
line1:0x50 19:45:22.312 1.0161 -0.0005 0.0078 0.0000 0.0000 0.0000 -25.9222 -89.4562 103.9691 0.0000
line1:0x50 19:45:22.412 1.0151 -0.0073 0.0073 0.0000 0.0000 0.0000 -26.3782 -89.4562 104.4745 0.0000
line1:0x50 19:45:22.519 1.0156 -0.0063 0.0073 0.0000 0.0000 0.0000 -26.5155 -89.4562 104.6173 0.0000
line1:0x50 19:45:22.610 1.0166 -0.0034 0.0093 0.0000 0.0000 0.0000 -26.6144 -89.4562 104.6942 0.0000

I have to convert it to a .xml written file
Thanks in advance

propositional logic – Converting to CNF – Distribution

I am still trying to get my head around what is valid CNF and how distribution works, I am not even sure if the examples I have tried to convert are correct for one, but I am also unsure of the rule for distribution and when I have looked at other posts here it seems so complicated and the actual rule does not seem to me to be obvious.

I think the correct process is:

  • Elimate Bi-Directionals
  • Eliminate Implications
  • Apply De Morgans Law
  • Apply Distributive Law

Clause One

A V B => C
-(A V B) V C -- Remove implication
(-A ^ -B) V C -- De Morgans Law
(-A V C) ^ (-B V C) -- Is this right? I am unsure of exactly how to distribute the or.

Clause Two

A ^ B => C
-(A ^ B) V C -- Eliminate Implication
(-A V -B) V C -- Is this now valid CNF or is there something more to do?

Clause Three

-A ^ -B => C
(A ^ B) V C -- Elimate Implication - Is this correct for a negated expression?
(A V C) ^ (B V C) -- Distribute OR - Is this correct?

I am not able to access the set of maths symbols for some reason so have used the notation in my course book.

I am currently taking a self taught course and have an exam in two weeks and I know there will conversion to CNF involved so I am trying to make sure I understand the steps now but I am still not entirely sure what is valid CNF.

The course material states it is a conjunction of disjunctions which I get, but then it seems to imply that: A V B V C V ..n is valid CNF?

opengl – Converting pixel coordinates/size to open gl coordinates’ system?

Is there a formula to draw, for example, a (100 * 200) rectangle on (10, 10) (regular 2D ortho coordinate) using opengl?

I have found no real define answers to this question on internet apart from this post.

public: float pixelToScreenX(int screen_width, int width, int x) { return (2.0 * tan(0.5 * width) * -1) * (width / screen_width) * -1; }

public: float pixelToScreenY(int screen_height, int height, int y) { return (2.0 * tan(0.5 * height) * -1) * (height / screen_height) * -1; }

Not working, it’s all equal to 0. I don’t understand the math so I can’t debug it myself.

I tried to use glOrtho but no matter where I place it, it has no effect on my code. That’s why i’m looking for a way around using math. But this is beyond my current level in math.

I found this if it can help you solve this problem.

My current drawing code (rect is just a class containing the rectangle coordinates & size) :

glBegin(GL_QUADS);
glColor(rect);

glVertex2f(0, 0);
glVertex2f(-100, 0);
glVertex2f(-100, 100);
glVertex2f(0, 100);

glEnd();

glFlush();

But what I wish to do is :

glBegin(GL_QUADS);
glColor(rect);

glVertex2f(rect.x, rect.y);
glVertex2f(rect.x1, rect.y);
glVertex2f(rect.x1, rect.y1);
glVertex2f(rect.x, rect.y1);

glEnd();

glFlush();

where rect.x etc.. are pixel coordinates converted to opengl coordinates.

Where rect.x, rect.x1, etc.. are (x, y) 2D ortho coordinates converted to opengl’s gibrish when I create my rectangle like this :

(...)
{
    color = Color(new_color);

    x = pixelToScreenX(screen_width, width, new_x);
    y = pixelToScreenY(screen_height, height, new_y);

    x1 = pixelToScreenX(screen_width, width, new_x + width);
    y1 = pixelToScreenY(screen_height, height, new_y + height);
}

Basically, I was wondering how can I write pixelToScreenWidth and pixelToScreenHeight

unity – HLSL Converting View Direction into Equiangular UVs

In Unity, I am attempting to create a custom skybox that use a single render texture to create a flat unmoving skybox (the render texture source will do it’s own movement) and reflect off objects as if it were an equiangular cubemap. So far using the unity custom skybox documentation I have been able to create a skybox with a flat image, however I have no idea how to read from the 2D render texture as if it were an equiangular cubemap. I’ve tried just using same UV coordinates from the skybox rendering pass as the reflection pass, but this results in a very small tiled reflection that looks very poor. I have also tried converting the view direction into cubemap uvs but this has the same result but with the entire image tiled.

What I am basically looking for is one of the following (but I am open to suggestions for better approaches):
1.) A way I can convert a float3 view direction into the uv coordinates needed to read from my image as if it were an equiangular cubemap.
2.) A way to convert the texture2D into an equiangular cubemap in real time every frame.

Here are some images I have taken of my current progress to show what I am looking for:
| | Sample Image | Test Pattern |
|-| ——– | ————– |
|Custom Skybox: Background Correct. Reflection Wrong| enter image description here | enter image description here |
|HDRI Skybox: Background Wrong. Reflection Correct| enter image description here | enter image description here |

Although this may not be helpful here is some of the shader code I am working on for reference:

Shader "Hidden/DontTouchMyStuff_OkayOnlyALittle_BeGentle/HDRP/Skyboxes/HdriFlatSky"
{
    HLSLINCLUDE

    // Some vertex shader stuff here, don't worry about it.

    ///////////////////////////////////////////////////////////////////
    // FRAGMENT SHADER
    ///////////////////////////////////////////////////////////////////
    float4 GetTextureColor(float4 screenPixelPosition)
    {
        return tex2D(_MainTex, float2(screenPixelPosition.x / _ScreenParams.x, screenPixelPosition.y / _ScreenParams.y));
    }

    // Renders reflected cubemap
    float4 FragBaking(Varyings input) : SV_Target
    {
        return GetTextureColor(input.positionCS); // tex2D(_MainTex, float2(4 * ((input.positionCS.x / _ScreenParams.x)), 4 * (1 - (input.positionCS.y / _ScreenParams.y))));
    }

    // renders sky, works perfectly so far.
    float4 FragRender(Varyings input) : SV_Target
    {
        UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
        float4 color = GetTextureColor(input.positionCS);
        color.rgb *= 1;// GetCurrentExposureMultiplier();
        return color;
    }
        
    // experiment to use direction as uvs. Didn't work, results in reflection like texture is every side of a cubemap.
    float4 Frag(Varyings input) : SV_Target
    {
        // Points towards the camera
        float3 viewDirWS = normalize(mul(float3(input.positionCS.xy, 1.0), (float3x3)_PixelCoordToViewDirWS));
        // Reverse it to point into the scene
        float3 dir = -viewDirWS;

        // Rotate direction
        float phi = 0.0;
        float cosPhi, sinPhi;
        sincos(phi, sinPhi, cosPhi);
        float3 rotDirX = float3(cosPhi, 0, -sinPhi);
        float3 rotDirY = float3(sinPhi, 0, cosPhi);
        dir = float3(dot(rotDirX, dir), dir.y, dot(rotDirY, dir));
        
        float3 dirAbs = abs(dir);
        float ma = 0;
        float2 uv = float2(0, 0);
        
        if (dirAbs.z >= dirAbs.x && dirAbs.z >= dirAbs.y)
        {
            ma = 0.5 / dirAbs.z;
            uv = float2(dir.z < 0.0 ? -dir.x : dir.x, dir.y);
        }
        else if (dirAbs.y >= dirAbs.x)
        {
            ma = 0.5 / dirAbs.y;
            uv = float2(dir.x, dir.y < 0.0 ? -dir.z : dir.z);
        }
        else
        {
            ma = 0.5 / dirAbs.x;
            uv = float2(dir.x < 0.0 ? dir.z : -dir.z, dir.y);
        }
        
        return float4(tex2D(_MainTex, uv * ma + 0.5).rgb, 1.0);
    }

    ENDHLSL

    SubShader
    {
        // For cubemap
        Pass
        {
            ZWrite Off
            ZTest Always
            Blend Off
            Cull Off

            HLSLPROGRAM
                #pragma fragment FragBaking
            ENDHLSL
        }

        // For fullscreen Sky
        Pass
        {
            ZWrite Off
            ZTest LEqual
            Blend Off
            Cull Off

            HLSLPROGRAM
                #pragma fragment FragRender
            ENDHLSL
        }
    }
}

Converting Canon 100D to WiFi

I can control my Canon 100D and store images on my laptop via a USB connection. I want to set up my camera outside and control it and see the images from inside without trailing a long cable. I have good WiFi coverage.

Is this possible? and what is the most cost effective approach? I have seen a WiFi enabled SD card for instance but this doesn’t let me control the camera. Is there such a thing as USB over WiFi, or are there any Canon specific gizmos that plug directly into the USB port of the camera to enable this?

Professionally converting text to audio, you can send a text file of 2000 sentences to it, and it wi for $10

Professionally converting text to audio, you can send a text file of 2000 sentences to it, and it wi

Professionally converting text to audio, you can send a text file of 2000 sentences to it, and it wiIf you are looking for good audio content to use in your work, beautiful images appear in this service professionally, you can in this service convert text to speech and voice

.

color correction – Converting RGB to Grayscale by reference

There is such a problem.

There is shooting on a color camera with a ColorChecker. And there is shooting on another, grayscale camera with the same color checker. Is it possible to somehow convert the first RGB image to the second (Grayscale) based on the ColorChecker?
I found a tutorial on how to do this in 3D Lut Creator, but it seems that the result is not completely accurate there.
How else can you do this?

magento2.3 – Amazon Sales Channel Extension – Existing Seller Central Acct – Magento 2.3.5, Orders not Converting

Background: I connected Amazon Sales Channel to an existing Amazon Seller Central account (mainly for the order import function). I have “import orders” set to enabled under Order Settings. I haven’t listed any products through the Magento Amazon Sales Channel interface (I used my existing listings), but it does show the account as active and shows all the orders from the Seller Central account in the Magento Amazon interface.

PROBLEM: None of the orders are converting to Magento orders. Since I’ve never seen this program work properly, how can I troubleshoot? There is a log tab but it shows empty. Are there any other logs on the server showing whats happing with the program? Are there any other steps that can be taken to figure out why its not converting orders to Magento Order management?

Ive tested on all 4.x versions of the Amazon Sales channel Extension with the same results so it could be configuration on my end.